PDA

View Full Version : Numbers



jcleaver
- 6th April 2007, 02:44
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?

SteveB
- 6th April 2007, 03:30
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

sayzer
- 6th April 2007, 09:35
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.

---------------------------

jcleaver
- 6th April 2007, 16:41
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

skimask
- 6th April 2007, 17:36
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...

jcleaver
- 6th April 2007, 23:18
thanks ski\
great reply probably more info than i can absorb
but you hit the nail on the head

skimask
- 7th April 2007, 00:15
thanks ski

I actually tried to drill in the info nice and gentle this time (for a change :) ).

sougata
- 7th April 2007, 08:25
Hi,

I am mentioning Floating Point. :D

jcleaver
- 7th April 2007, 13:25
where is info on using this in pbp manual or others

thanks

HenrikOlsson
- 7th April 2007, 14:11
Hi,
Info on using Microchips FP routines with PBP is available here:
http://www.melabs.com/resources/fp.htm

/Henrik Olsson.

jcleaver
- 7th April 2007, 16:23
thank everybody for there help
great answers

skimask
- 7th April 2007, 18:32
where is info on using this in pbp manual or others

thanks

And yet again...no floating point in PBP. All math that PBP can handle is mentioned in the manual. No decimal points, no fractions, no halves, no thirds, no tenths, no hundreths, no nothing. Just whole numbers.