Fun with ArrayBuffers
Tony Cox <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.xpfe |
|---|---|
| Organization | http://groups.google.com |
| Message-ID | <19481893.2538.1328045452511.JavaMail.geo-discussion-forums@vbxy22> |
I'm hoping somebody can tell me where I am going wrong using typed array buffers. I am parsing a binary stream. Uint32 drop out very nicely using this function:
readUint32: function(stream) {
var u = new Uint8Array(stream.readByteArray(4));
return new Uint32Array(u.buffer)[0];
},
But the equivalent for Float32 fails. I just cannot work out why....
readFloat32: function(stream) {
var u = new Uint8Array(stream.readByteArray(4));
return new FLOAT32Array(u.buffer)[0];
},
Any help very gratefully received.