Convert 64Bit Double to 32Bit Float Node.Js

I'm reading 64bit-doubles from a buffer by the function: http://nodejs.org/api/buffer.html#buffer_buf_readdoublele_offset_noassert .

Is it possible to round these 64-bit-values to 32-bit-values in an efficient way?

Thx.

In Node.js 0.11 with the -harmony_maths flag you can simply use Math.fround():

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

In Node.js 0.10.25 use Float32Array:

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

See Efficient float32 arithmetic in JavaScript