Quote Originally Posted by keithdoxey
PBP only works with Integers not floating point.

what is the biggest number you would ever end up using ?

Using your example without the decimal point you would have 104717 which is too big for a word (65535).

If you could lose the least significant digit then you would have 10471 (or you could choose to make it 10472 based on the digit you are losing.

Remember that you only had 3 digits after the point.

Divide that by 60 and you get 174 which will equate to 0.174

Divide by 6 instead and you get 1745 and can now allow for 4 digits after the point as you had already reduced your divisor by a factor of 10 so that will equate to 0.1745

Is that accurate enough for your needs ?

Failing that, search the forum for "Floating Point"

Melanie will no doubt offer a far better solution shortly due to her much greater knowledge of solving problems with PBP

Regards

Thanks Keith! I actually have it working for 5 digits, but would really like to use the 6th digit. the highest the number would be is 599,999. The problem is, in order to add the 6th digit i'd need to do something like this:


word = word
tmp = byte

for i = 0 to 5
word = word*10 + tmp[i]
next i

where i'm storing it in a word, and adding tmp[i]. Of course, this works fine up until i exceed a valid word on the last iteration.

If i didn't need to add tmp[i] (the 6th digit) i could just directly use DIV32 with no worries, but adding the tmp[i] term would not allow me to use DIV32 since the DIV32 needs to execute immediately after the multiplication, right?