- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Node.js – v8.serializer.writeDouble() Method
The v8.serializer.writeDouble() method is used for writing a double value to the internal buffer. This method is for use inside the serializer._writeHostObject().
Syntax
v8.serializer.writeDouble(value)
Parameters
It takes a single parameter −
value − This parameter takes input for the double value that needs to be written inside the internal buffer.
Example 1
Create a file with the name "writeDouble.js" and copy the following code snippet. After creating the file, use the command "node writeDouble.js" to run this code.
// v8.serializer.writeDouble() Demo Example // Importing the v8 module const v8 = require('v8'); // Defining a new object for v8 serializer const serializer = new v8.Serializer(); // Printing the double number in the internal buffer console.log(serializer.writeDouble(12345.6789)); // Releasing buffer to print the value on console console.log(serializer.releaseBuffer());
Output
C:\home
ode>> node writeDouble.js undefined <Buffer a1 f8 31 e6 d6 1c c8 40>
Example 2
Let’s have a look at one more example -
// v8.serializer.writeDouble() Demo Example // Importing the v8 module const v8 = require('v8'); // Defining a new object for v8 serializer const serializer = new v8.Serializer(); function writeDouble(data) { serializer.writeDouble(data); console.log(data); console.log(serializer.releaseBuffer()); } writeDouble(12.22); writeDouble(345.90); writeDouble(0.1);
Output
C:\home
ode>> node writeDouble.js 12.22 <Buffer 71 3d 0a d7 a3 70 28 40> 345.9 <Buffer 66 66 66 66 66 9e 75 40> 0.1 <Buffer 9a 99 99 99 99 99 b9 3f>
Advertisements