防止 toFixed 舍入非常小的十进制数
Prevent toFixed from rounding off very small decimal numbers
我的值非常小,0.09986684420772304,我想将它显示为小数点后三位。 toFixed 四舍五入。
(0.09986684420772304).toFixed(3) ==> 0.100
我什至试过了
(Math.round(0.09986684420772304 * 100)/100).toFixed(3) => 0.100
我需要的是
(0.09986684420772304).toFixed(3) ==> 0.0998
请有人给我一个解决方案
(0.09986684420772304).toPrecision(3)
或Math.floor(0.09986684420772304 * 10000) / 10000
我的值非常小,0.09986684420772304,我想将它显示为小数点后三位。 toFixed 四舍五入。
(0.09986684420772304).toFixed(3) ==> 0.100
我什至试过了
(Math.round(0.09986684420772304 * 100)/100).toFixed(3) => 0.100
我需要的是
(0.09986684420772304).toFixed(3) ==> 0.0998
请有人给我一个解决方案
(0.09986684420772304).toPrecision(3)
或Math.floor(0.09986684420772304 * 10000) / 10000