Kirk Ouimet
Kirk Ouimet

Reputation: 28384

What are UInt16LE, UInt16BE, etc. in Node JS?

In all of my time programming I have squeaked by without ever learning this stuff. Would love to know more about what these are and how they are used:

See https://nodejs.org/api/buffer.html#buffer_buf_readuint8_offset_noassert for where Node uses these.

Upvotes: 1

Views: 4565

Answers (1)

Dmitry Poroh
Dmitry Poroh

Reputation: 3825

This datatypes are related to number representation in appropriate byte-order. It typically essential for:

  • Network protocols
  • Binary file formats

It is essential because one system should write integers/floats in such way that will give the same value on reader side. So what format to be used is just convention between two sides (writer and reader).

What acronyms means:

  • BE suffix stands for BigEndian
  • LE stands for LittleEndian
  • Int is Integer
  • Uint is Unsigned Integer

Appropriate number in integers is number of bits in the word.

Upvotes: 1

Related Questions