相关疑难解决方法(0)

为什么我在ECMAScript/ActionScript 3中看到不精确的浮点结果?

嘿,让我们直接跳转到一个代码示例显示的ECMAScript/JavaScript的/ AS3怎么不能做简单的数学权(AS3使用了数类的IEEE-754双精度浮点数"按理说它是相同的用于JavaScript)...

trace(1.1);         //'1.1': Ok, fine, looks good.
trace(1.1*100);     //'110.00000000000001': What!?
trace((1.1*100)/100);  //'1.1': Brings it back to 1.1 (since we're apparently multiplying by *approximately* 100 and then dividing by the same *approximate* '100' amount)
trace(1.1*100-110); //'1.4210854715202004e-14': Proof that according to AS3, 1.1*100!=110 (i.e. this isn't just a bug in Number.toString())
trace(1.1*100==110);   //'false': Even further proof that according to AS3, 1.1*100!=110
Run Code Online (Sandbox Code Playgroud)

是什么赋予了?

javascript floating-point actionscript-3

1
推荐指数
1
解决办法
998
查看次数