??? 08/05/07 21:05 Read: times |
#142788 - Working within the range of long integers Responding to: ???'s previous message |
Stanley Lio said:
Why is this happen? Or it just happened to work? tmp = 65536 - (10 * AxisAngle + 460) * 221184 / 120000; float = long - (int * char + int) * long / long; float = long - (int + int) * long / long; float = long - (int) * long / long; float = long - long / long; float = long - long; float = long; It didn't just happen to work. Your original statement caused long integer overflow. Your second version factored out 100, which reduced the range of the subexpressions to always be within the range of a long integer. You never were taking (dis)advantage of floating point. |