Decimal fractions

Andrew Cowan

Senior Member
No, integers only.

However, by multiplying by 100 (then dividing by 100 at the end (either by rounding or splitting up the number into parts), 9.17 can be represented (as 917).
 

westaust55

Moderator
to expand upon the information provided by andrew,

if you have a constant 9.17

then use 917

so you might have

w1 = b0 * 917

then the whole part is

w1/100

the fraction is

w1 // 100


if you only want to print out the result then read up on the BINTOASCII command

either way you can then print the whole part, a period (".") and then the decimal fractional part
 

westaust55

Moderator
Thanks. Never knew that one. Very close indeed.

Not so good but easier to code without overflow is 22/7.
Overflow is very certainly a consideration.

whether using byte or word variables, 65,535 is the largest number that can be handled internally (16-bit).

While 355 can be a constant to avoid using a word variable, to avoid overflow with simple maths, the largest number you can have prior to multiplying by 355 is 186.

Whereas with the well known 22/7 approximation you can have a value up to 29,797 before multiplying with 22 and not end up with overflow.
 
Top