Node.js Buffer.writeDoubleLE() Method
The Buffer.writeDoubleLE() Method is an inbuilt application programming interface of class Buffer within Buffer module that writes a value to the buffer at the specified offset with the specified endian format. Note that the value must be a valid 64-bit double.
Syntax:
Buffer.writeDoubleLE(value, offset)
Parameters: This method accepts two parameters as mentioned above and described below:
- value: This parameter holds a number that is to be written to the buffer.
- offset: This parameter holds the number(integer) of bytes to skip before starting to write.
Return value: It returns the offset along with a number of bytes written.
Example 1:
javascript
const buf = Buffer.allocUnsafe(8);
buf.writeDoubleLE(123.456, 0);
console.log(buf);
|
Output:
<Buffer 77 be 9f 1a 2f dd 5e 40>
Example 2:
javascript
const buf = Buffer.allocUnsafe(16);
buf.writeDoubleLE(0xcafebabe, 4);
console.log(buf);
|
Output:
<Buffer 28 83 db 7c 00 00 c0 57 d7 5f e9 41 00 00 00 00>
Reference:https://nodejs.org/api/buffer.html#buffer_buf_writedoublele_value_offset
Last Updated :
11 Apr, 2023
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...