Groups | Blog | Home
all groups > flash actionscript > july 2007 >

flash actionscript : Error in Round


Patrick B
7/19/2007 6:26:06 PM
Neat. This may actually be a Flash bug. Here's the calculation:

var num:Number=1.265;
num*=100;
trace ('num='+num);
trace(Math.round(num)/100);

....and here's the trace:

num=126.49999999999999
1.26

So it explains why the number is being rounded the way it is but clearly
the result is wrong. This might be something to bring to Adobe's attention!

Regards,
Patrick

[quoted text, click to view]

--
http://www.baynewmedia.com
Faster, easier, better...ActionScript development taken to new heights.
Download the BNMAPI today. You'll wonder how you ever did without it!
Yorchxxx
7/19/2007 9:57:40 PM
I try thist:
trace(Math.round(1.265*100)/100); Flash Result: 1.26 Error, the correct answer it's 1.27
Any Ideas?

AddThis Social Bookmark Button