Node.js Buffer.writeFloatBE() Method
The Buffer.writeFloatBE() method is an inbuilt application programming interface of class Buffer within the Buffer module which is used to writes big endian 32 bits floating point value to an allocated buffer at the specified offset.
Buffer.writeFloatBE( value, offset )
Parameters: This method accept two parameters as mentioned above and described below:
- value: This parameter specifies 4 bytes floating point value to be written to the buffer. It should be a valid 32 bits big endian floating point value. Behavior is undefined when value is anything other than this.
- offset: It specifies the number of bytes to skip before write or simply signify the index in the buffer. The value of offset lies 0 <= offset <= Buffer.length – 4. Its default value is 0.
Return Value: This method returns an integer value that is the sum of offset and number of bytes written in big endian format.
Below examples illustrate the use of Buffer.writeFloatBE() method in Node.js:
4 8 12 16 <Buffer 4f 3a be fb 00 00 00 00 4f 80 00 00 4f 4a bc bd>
Before writing into buffer: <Buffer 00 00 00 00 00 00 00 00> 4 8 After writing into buffer: <Buffer 4f 3a be bb 4f 5e ca de>
Note: The above program will compile and run by using the
node index.js command.