Typical problem of word size and technique.
Take i = 220
Now, plug into the formula
220-179 = 41
41 * 1623 = 66543
which ends up in the variable as 66543-65535(0FFFFH) = 1008
Now, you do the rest of the math and end up with the 1%
You need to re-factor the way you calculate the problem.
Bookmarks