|
Re: Floating point math zero
At first I suspected that the problem had to do with integer overflow at this step:
(float)(prettyJoyX*prettyJoyX + prettyJoyY*prettyJoyY)
However, assuming prettyJoyX and prettyJoyY are bounded at +/- 127, this wouldn't cause an overflow. Obviously, it also would never be negative. If it isn't the case that those variables are bounded, then it could be possible that you are overflowing, causing the data to wrap around to a negative number and invalidating "sqrt".
I will continue investigating.
For what values of prettyJoyX and prettyJoyY do you get zero?
|