u32View = new Uint32Array(conversionStorage);
function u32ToF32(x) {
u32View[0] = x;
return f32View[0];
}
function f32ToU32(x) {
f32View[0] = x;
return u32View[0];
}
You want DataView
This is a more manual way to do the same thing I think, but the way to avoid allocations is to reuse the buffer in both cases, the buffer should just live forever or be a parameter to the conversion functions
The buffer is a global variable and reused.
Обсуждают сегодня