-
need help with sumple add subtract problem
why is this happening?
if you use a calculator or google 310 + (-303.3) you will get 6.7
but when i do this is AS3 trace(310 + (-303.3)); i get 6.699999999999989
i tried Math.ceil() and round() but cant get 6.7
TY
Last edited by mikemx; 12-01-2008 at 03:49 AM.
-
Flashkit Veteran
Probably has to do with the integer conversion type in Flash, try 310.0-(-303.3)
I have had the same problem in Java, of course the compiler won't even let me subtract a double from an integer in that language.
But my guess is that the compiler resets the 310 value to 310.00000000000000... in hopes of retaining double level precision. Try it out, tell me what happens I haven't used 3.0 so just offering my humble advice
-
nope,
if i try 310.0-(-303.3) like you suggest i get 613.3
so i tried
trace(310.0 + (-303.3)) get 6.699999999999989
-
Flashkit Veteran
That is quite odd and I am very sorry, but I know little about the changes made in AS3 so my knowledge is limited, as if it wasn't already :P
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|