Numbers


Closed Thread
Results 1 to 12 of 12

Thread: Numbers

Hybrid View

  1. #1

    Exclamation Numbers

    Anyone Know A Way To Include Dec Numbers
    Such As 1.2 4.3 Or Any With Decimal Points
    Pbp Seems To Dislike Fraction Numbers

    How To Incorporate This Type Of Number?

  2. #2
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default

    Something to ponder. For the most part, the decimal point is arbitrary. If you are going to work with numbers limited to the range of 0.0 thru 6553.5, just use a WORD type variable, forget about the decimal point, and when a human will read it, plop a "." between the 1st and 2nd digits (counting from the right). It's a simplistic explaination, but hopefully you get the point and can extrapolate from there. More "accuracy", you are limited to 0.00 thru 655.35.

    Beyound that, there are FP routines that you can get from MeLabs website. Knock yourself out!

    SteveB

  3. #3
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    jcleaver,

    As SteveB says, you can go around it as below.

    Say you have to divide 6 by 5.
    6/5= 1.2

    In PBP, you will get the result as (1).
    Result = 1

    But there is something called "remainder". You can check this in manual.

    Then you can hold the remainder (2) in another variable.
    Floating = 2

    Then you can put them together or collect them in a single variable.
    If it is only for display purposes then the job is easier.

    ---------------------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  4. #4


    Did you find this post helpful? Yes | No

    Default ?

    thanks for the responce however i was not clear enough
    i am trying to divide a number by a fraction number

    1000/7.5 as a example pbp gives error on the 7.5 or any number with a decimal point

    thanks

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by jcleaver View Post
    thanks for the responce however i was not clear enough
    i am trying to divide a number by a fraction number

    1000/7.5 as a example pbp gives error on the 7.5 or any number with a decimal point

    thanks
    Then take your numbers, multiply them by 10 beforehand to get rid of the decimal point, do the division, then divide them by 10 afterwards.
    PBP does NOT deal with any sort of fractions at all. PBP only deals with straight INTEGERs, whole numbers, no floating points, no decimal points, no halves, no quarters, no tenths, no nothing.

    PBP runs on a PIC. A PIC is a microcontroller. A microcontroller runs by 'interpreting' (for lack of a better word) binary code. Binary numbers, base 2 numbering, no matter which language you are dealing with, only have states; 1 and 0, on and off, up or down, left or right, yes or no, true or false, voltage or no voltage, positive or negative, day or night, open or shut, and so on...

    There is no 1/2 on, 1/2 up, 3/4 left, partially true, a little voltage, somewhat positive, almost day, 1/2 way open...etc. To do any of these would introduce something that the binary numbering system doesn't not have; a decimal point.
    Can you create a decimal point? Sure, in a way. If you couldn't, your PC couldn't handle math, you couldn't calculate pi, do any trig, etc.
    I could go on and on...but now I'm bored and somebody can probably pick up the conversation from here...

  6. #6


    Did you find this post helpful? Yes | No

    Talking wow

    thanks ski\
    great reply probably more info than i can absorb
    but you hit the nail on the head

Similar Threads

  1. Working with 3 byte numbers
    By Josuetas in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 26th July 2007, 22:59
  2. Splitting numbers and recombining them(EEPROM Error)
    By selbstdual in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 3rd June 2007, 06:40
  3. Returning whole numbers for DS1820?
    By jessey in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 12th February 2007, 12:15
  4. Multiplying large numbers
    By jhonea1 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 14th April 2006, 17:41
  5. Storing numbers for caller ID?
    By Rob Martin in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 28th March 2005, 10:27

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts