Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

node.js

What is readDoubleLE() in the Node.js Buffer Module?

Abdul Monum

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Buffer Module in Node.js provides access to Buffer objects that represent fixed-length sequences of bytes. readDoubleLE() is a method defined in the Buffer Class that reads a 64-bit, little-endian double from the Buffer object starting from the specified offset. The prototype of readDoubleLE() is as follows:

buf.readDoubleLE([offset])

Parameters

offset: Number of bytes to skip before reading. offset must be an integer and lie in the range 0<=offset<=buf.length80<= offset <= buf.length -8. The default value is 00.

Return value

64-bit, little-endian double from buf starting from the specified offset.

NOTE: Buffer Class is accessible within the global scope. Therefore, you do not need to use the require('buffer').Buffer method to import the Buffer Module.

Example

const buf = Buffer.from([1, 62, -83, 4, 25, 6, 37, 18, -10]);
console.log(buf.readDoubleLE(1));

Explanation

In the first line, we create the buffer object buf using Buffer.from(). Then, we display the 64-bit, little-endian double value from buf after skipping 1 byte by passing offset 1 to the buf.readDoubleLE() method.

RELATED TAGS

node.js

CONTRIBUTOR

Abdul Monum
Copyright ©2022 Educative, Inc. All rights reserved

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring