i'm having problems with some really basic calculations, i dont know whether it's a bug w/ flash, or if there's something wrong with my script.. the scenerio is like this, i have some buttons for the users to click on the following items:
0.01, 0.05, 0.10, 0.25, 1.00, 2.00, 5.00, 10.00, 20.00
when the total amount goes above 5, then 9 clicks of 0.05, 10 clicks of 0.10 are made, the amount is supposed to be 6.45, but it turns out to be 6.4499999999, i've tried all the possible combinations, it still turns out like this when the amount is >5, it's the same for 7.45, 8.45 and so on
could anyone pleaseeee tell me what's wrong? if it's the way how the calculations are done in flash MX? or is it possible to use the sum of the calculations up to 2 decimal places only so that the 6.4499999999 would show up as 6.45 instead? i cant think of any way to solve this problem, unless i force the calculations to add on the extra 0.0000000001
and it's weird that some code works fine in a function that i called, but the exact same code woudn't work in some other part, i had to copy & paste the part that worked to replace the part that wouldn't work, what could be the reasons causing all that problem? a bug within flash?!
I would have advised math.round(your_result). It appears that the math.ceil() method does the same thing, the difference seems to be that math.ceil() always rounds up.
I didn't even know math.ceil() was there. Good to know! A star for Old.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.