2014-08-28 75 views

回答

1

在Node.js的0.11与-harmony_maths标志,你可以简单地使用Math.fround()

Math.PI - Math.fround(Math.PI) // -8.742278012618954e-8 

在Node.js的0.10.25使用Float32Array

var fa = new Float32Array(1); 
fa[0] = Math.PI 
Math.PI - fa[0] // -8.742278012618954e-8 

Efficient float32 arithmetic in JavaScript