I want to convert a binary array (which I receive as Uint8Array
) to a Float32Array
, by simply concatenating tuples of 4 bytes. I do not want convert each single Uint8
to a Float32
(which is why this is no duplicate of this post).
It has been suggested in answers like this one to simply do something like this (to be exact, this recommendation is actually for the conversion in the opposite direction):
var floatShared = new Float32Array(uint8array.buffer);
According to this answer, both array do now share the same buffer in the background, which would be exactly what I need. However my floatShared
seems to not get updated properly as the length still remains 0 and I cannot inspect it in the browser.
Am I missing a step or am I going in the completely wrong direction? How can I do this conversion?