谁能解释一下吗?
我是什么做错了吗?
Math.Round(X:编号)x舍入到最近的整数值。在你的情况下,28是28.499999999999996最接近的整数值。因此,这里的行为是正确的。什么是奇怪的是,0.285 * 100不是28.5,但毕竟是在AS3 Number类的precision的结果。下面是关于这一点,多一点信息,可能的解决方案:
Math.Round(x:Number) rounds x to the nearest integer value. In your case 28 is the nearest integer value for 28.499999999999996. So here the behavior is correct. What is weird is that 0.285 * 100 is not 28.5, but that is a consequence of the precision of the Number class in as3. Here is a little more information about this and a possible solution:
Innacurate数学成绩
另外可以看到此等问题:
Also you can see this SO question:
Very陌生号码的操作问题
希望这有助于。