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?
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?
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
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
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...
thanks ski\
great reply probably more info than i can absorb
but you hit the nail on the head
Bookmarks