In a buffer I have a sequence of bytes read from a file. And I need to represent them as a sequence of float32. Size of each file data block is about 15KB so I don't want to copy from this buffer to another.
I've read a lot regarding Float32Array.from
, for instance, here. In the resulting presentation figures changes, but they are still integer and their number still the same.
The code:
console.log('total points: ' + res.trans.length);
console.dir(res.trans);
console.log(Float32Array.from(res.trans));
console.log('total float points: ' + Float32Array.from(res.trans).length);
The result:
total points: 9504
Buffer(9504) [Uint8Array] [ 187, 97, 63, 187, 205, 183,
Float32Array(9504) [ 187, 97, 63, 187, 205,...
total float points: 9504
In a browser: