You do know that PBP does NOT deal with fractions and decimals...right?
a var word
b var word
'start with a number in b
1 - b = 655 ' maximum value in b is 655, otherwise word variable b will overflow
2 - b = b * 100 'shift the decimal point over to right 2 places temporarily
3 - a = b / 558 'constant value of 5.58 also has it's decimal point shifted over by 2 places
1 - b = 655 (given)
2 - b = 65500 (closest you can get without overflowing a word value)
3 - a = 117 ( 65500 / 558, PBP doesn't do fractions)
Do a search on 'decimal' and 'fraction' here and you'll find some stuff. Otherwise, download the floating point math routines from microchip if you need good accuracy.
Bookmarks