4 Replies Latest reply on Nov 30, 2006 10:27 AM by kglad

# Simple arithmatic function is not resulting in zero

This is absolutely bizarre. 2.4 - 1.2 = 1.2 and 1.2-1.2 = 0, or so you'd think, except that Flash keeps telling me 1.2 - 1.2 = -4.44089209850063e-16. Subtract 1.2 once more from -4.44089209850063e-16 and you miraculously get -1.2. Even more bizarre is that this only happens if the starting value is greater than 2.4.

See attached code which began as something much more complex but I've commented out absolutely EVERYTHING except for this little bit of math and yet it keeps telling me that 0 is -4.44089209850063e-16. But only if rpm is greater than 2.4 to start with. If it's 2.4 or less, it does get to zero.

Thanks for any help.
• ###### 1. Re: Simple arithmatic function is not resulting in zero
P.S. the ClipButton class is just button behaviours on a movie clip: up, over, down. It's what I use instead of Flash Buttons.
• ###### 2. Re: Simple arithmatic function is not resulting in zero
0 = -4.44089209850063e-16 within 15 digits which is the limit of accuracy within flash.
• ###### 3. Re: Simple arithmatic function is not resulting in zero
But why doesn't it return the whole numeral 0? And how do I get it to without rounding to whole numbers? I just want 0 and, in fact, I need it, for the rest of my script to work.

Thanks.
• ###### 4. Re: Simple arithmatic function is not resulting in zero
1. because your computer uses binary arithmatic.

2. you must round to get zero but you don't need to round to whole numbers. you can round to within 15 digits and then you'll get zero and won't loose any significant accuracy for most purposes.