Security News
How Threat Actors are Abusing GitHub’s File Upload Feature to Host Malware
GitHub is susceptible to a CDN flaw that allows attackers to host malware on any public repository.
ieee754
Advanced tools
Package description
The ieee754 package provides functions to read and write IEEE 754 floating-point numbers from and to a Buffer or array-like object. This is particularly useful for dealing with binary data formats that require precise handling of floating-point numbers according to the IEEE 754 standard, which is widely used in computing.
Reading floating-point numbers
This feature allows you to read IEEE 754 floating-point numbers from a buffer. The example demonstrates reading a 32-bit floating-point number (in this case, an approximation of Pi) from a buffer.
const ieee754 = require('ieee754');
let buffer = new Buffer([0x40, 0x49, 0x0f, 0xd0]);
let value = ieee754.read(buffer, 0, true, 23, 4);
console.log(value); // Outputs: 3.1415927410125732
Writing floating-point numbers
This feature enables you to write IEEE 754 floating-point numbers to a buffer. The example shows how to write the value of Pi as a 32-bit floating-point number into a buffer.
const ieee754 = require('ieee754');
let buffer = new Buffer(4);
ieee754.write(buffer, Math.PI, 0, true, 23, 4);
console.log(buffer); // Outputs: <Buffer 40 49 0f db>
bignumber.js is a JavaScript library for arbitrary-precision decimal and non-decimal arithmetic. Unlike ieee754, which focuses on IEEE 754 binary floating-point arithmetic, bignumber.js provides more general-purpose arithmetic operations with high precision, making it suitable for financial and other applications requiring exact calculations.
decimal.js is another library for arbitrary-precision arithmetic, similar to bignumber.js. It also focuses on decimal arithmetic rather than binary floating-point, offering precision and operations beyond the IEEE 754 standard. Compared to ieee754, decimal.js is more versatile for applications needing decimal precision and complex arithmetic operations.
Readme
npm install ieee754
var ieee754 = require('ieee754')
The ieee754
object has the following functions:
ieee754.read = function (buffer, offset, isLE, mLen, nBytes)
ieee754.write = function (buffer, value, offset, isLE, mLen, nBytes)
The arguments mean the following:
write
)The IEEE Standard for Floating-Point Arithmetic (IEEE 754) is a technical standard for floating-point computation. Read more.
BSD 3 Clause. Copyright (c) 2008, Fair Oaks Labs, Inc.
FAQs
Read/write IEEE754 floating point numbers from/to a Buffer or array-like object
The npm package ieee754 receives a total of 33,966,788 weekly downloads. As such, ieee754 popularity was classified as popular.
We found that ieee754 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub is susceptible to a CDN flaw that allows attackers to host malware on any public repository.
Security News
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
Research
Security News
The Socket Research team found this npm package includes code for collecting sensitive developer information, including your operating system username, Git username, and Git email.