Help needed with "simple" math calculation

reywas

Member
Here's the code:

w9=0
main:
inc w9
w10 = w9*559/1150
debug
pause 2000
goto main

The problem:

when w9=117, w10=56 (that's correct)
when w9=118, w10= 0 (should be 57)

What's going on here?

Edit: Ok, I see that 118*559 is larger than 65535 and is over-running the register. I guess I need to scale the numbers in the equation.

w10=w9*56/115
 
Last edited:

lbenson

Senior Member
Nice. All in one post.

1) problem detected
2) condition where problem begins identified
3) cause of problem identified
4) solution provided (if accuracy sufficient for need is attained)
 
Top