3 Replies Latest reply on Jul 5, 2006 10:31 PM by eaglecat

# Zero not Zero!

I have two values, angles in radians, that I compare in an if statement. "if(a==b){do this}". I trace 'a' and 'b' and I can see that they are the same. I have even rounded the values to 4 decimal places. They trace as the same but the 'do this' does not run every time. So i did a trace of (a - b) and the result was not zero (it should of been) and of course the 'do this' did not run. (a-b) traced 2.354647749883643e-23 or something like that. when it traced zero it did work. My question is: if a = 0.1735 and b=0.1735 then why does Flash throw up (a-b) = 2.354647749883643e-23?

Romba
• ###### 1. Re: Zero not Zero!
because flash does arithmetic using binary computers like most other software. and N*e-23 is zero within 22 decimal places (for N<10).
• ###### 2. Re: Zero not Zero!
have a look at previous threads here and here
• ###### 3. Re: Zero not Zero!
thanks craig. With new knowledge I rejigged the if statement to if(a < 0.00001 || b < 0.00001) and it worked fine.