buffer.readInt16LE()

buf.readInt16LE(offset[, noAssert])

Reads a signed 16-bit integer from the Buffer at the specified offset with the specified endian format (readInt16BE() returns big endian, readInt16LE() returns little endian).

Setting noAssert to true skips validation of the offset. This allows the offset to be beyond the end of the Buffer.

Integers read from the Buffer are interpreted as two's complement signed values.

const buf = Buffer.from([1,-2,3,4]);

buf.readInt16BE();
  // returns 510
buf.readInt16LE(1);
  // returns 1022
doc_Nodejs
2016-04-30 04:37:39
Comments
Leave a Comment

Please login to continue.