Node.js Buffer.writeFloatBE() Method Last Updated : 13 Oct, 2021 Comments Improve Suggest changes Like Article Like Report 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. Syntax: 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: Example 1: javascript // Node.js program to demonstrate the // Buffer.writeFloatBE() method // Allocating 16bytes buffer const buf = Buffer.allocUnsafe(16); // Writing 32bit or 4 byte floating point // values to the buffer and printing // returned value to console console.log(buf.writeFloatBE(0xbabeface, 0)); console.log(buf.writeFloatBE(0x00000000, 4)); console.log(buf.writeFloatBE(0xffffffff, 8)); console.log(buf.writeFloatBE(0xcabcbcbc, 12)); // Printing the buffer console.log(buf); Output: 4 8 12 16 <Buffer 4f 3a be fb 00 00 00 00 4f 80 00 00 4f 4a bc bd> Example 2: javascript // Node.js program to demonstrate the // Buffer.writeFloatBE() method // Allocating 8bytes buffer const buf = Buffer.allocUnsafe(8); // Printing buffer before writing value console.log("Before writing into buffer:"); console.log(buf); // Writing 32bits or 4 bytes floating // point values to the buffer and // printing returned value to console console.log(buf.writeFloatBE(0xbabebabe, 0)); console.log(buf.writeFloatBE(0xdecade20, 4)); // Printing the buffer after writing into buffer console.log("After writing into buffer:"); console.log(buf); Output: 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. Reference: https://nodejs.org/api/buffer.html#buffer_buf_writefloatbe_value_offset Create Quiz Comment G gekcho Follow 0 Improve G gekcho Follow 0 Improve Article Tags : Web Technologies Node.js Node.js-Buffer-module Explore Introduction & Installation NodeJS Introduction3 min readNode.js Roadmap: A Complete Guide6 min readHow to Install Node.js on Linux6 min readHow to Install Node.js on Windows5 min readHow to Install NodeJS on MacOS6 min readNode.js vs Browser - Top Differences That Every Developer Should Know6 min readNodeJS REPL (READ, EVAL, PRINT, LOOP)4 min readExplain V8 engine in Node.js7 min readNode.js Web Application Architecture3 min readNodeJS Event Loop5 min readNode.js Modules , Buffer & StreamsNodeJS Modules5 min readWhat are Buffers in Node.js ?4 min readNode.js Streams4 min readNode.js Asynchronous ProgrammingAsync Await in Node.js3 min readPromises in NodeJS7 min readHow to Handle Errors in Node.js ?4 min readException Handling in Node.js3 min readNode.js NPMNodeJS NPM6 min readSteps to Create and Publish NPM packages7 min readIntroduction to NPM scripts2 min readNode.js package.json4 min readWhat is package-lock.json ?3 min readNode.js Deployments & CommunicationNode Debugging2 min readHow to Perform Testing in Node.js ?2 min readUnit Testing of Node.js Application5 min readNODE_ENV Variables and How to Use Them ?2 min readDifference Between Development and Production in Node.js3 min readBest Security Practices in Node.js4 min readDeploying Node.js Applications5 min readHow to Build a Microservices Architecture with NodeJS3 min readNode.js with WebAssembly3 min readResources & ToolsNode.js Web Server6 min readNode Exercises, Practice Questions and Solutions4 min readNode.js Projects9 min readNodeJS Interview Questions and Answers15+ min read Like