en.javascript.info icon indicating copy to clipboard operation
en.javascript.info copied to clipboard

Mention endianness and alignment in section ArrayBuffers, binary arrays

Open starblue opened this issue 4 years ago • 1 comments

  • Alignment: My browser (Firefox 87.0 on Linux x86_64) doesn't let me create an unaligned Uint16Array. I. e., new Uint16Array(b, 1, 1) on a 4-byte array buffer gives RangeError: attempting to construct out-of-bounds TypedArray on ArrayBuffer. In the standard that is 22.2.1.5.13a.

  • Endianness: Uint16Array is little-endian on my machine. I just learned that this is machine dependent (https://stackoverflow.com/questions/7869752/javascript-typed-arrays-and-endianness). In contrast, dataView.getUint16() is big-endian, unless the second argument is true.

Hope this helps.

starblue avatar Apr 17 '21 11:04 starblue

I guess, most readers don't know what an endian is. Not sure we need to delve into this.

Can we give a reference maybe?

iliakan avatar May 13 '21 14:05 iliakan