document.writeln(Math.floor(43.9));
在浏览器中,这会输出43。
document.writeln(Math.floor(43.9999));
产生 43
document.writeln(Math.floor(43.999999999999));
again 43
However,
document.writeln(Math.floor(43.99999999999999));
产生44。
为什么是这样呢?在小数点后面连续9个9的神奇数字似乎是15*。
此外,Math.floor函数接受数字对象还是数字值作为参数?
0.1 + 0.2 !== 0.3
这件事,对吧?:)
您的观察可能是这个主题的一个变化。 - Šime Vidas