Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@xtuc/ieee754

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@xtuc/ieee754

Read/write IEEE754 floating point numbers from/to a Buffer or array-like object

  • 1.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
15M
increased by55.44%
Maintainers
1
Weekly downloads
 
Created

What is @xtuc/ieee754?

The @xtuc/ieee754 package provides utilities for encoding and decoding floating-point numbers according to the IEEE 754 standard. This standard is widely used for floating-point arithmetic in computer systems, and this package allows for direct manipulation of binary representations of these numbers in JavaScript.

What are @xtuc/ieee754's main functionalities?

Encoding floating-point numbers

This feature allows you to encode a JavaScript floating-point number into its IEEE 754 binary representation. The code sample shows how to write the number 123.456 into a buffer at a specified offset using the ieee754.write function.

const ieee754 = require('@xtuc/ieee754');
let buffer = new ArrayBuffer(8);
let view = new DataView(buffer);
ieee754.write(view, 123.456, 0, false, 52, 8);

Decoding floating-point numbers

This feature allows you to decode a binary representation of a floating-point number back into a JavaScript number. The code sample demonstrates reading a number from a buffer where it was previously stored using the DataView's setFloat64 method, and then decoding it with ieee754.read.

const ieee754 = require('@xtuc/ieee754');
let buffer = new ArrayBuffer(8);
let view = new DataView(buffer);
view.setFloat64(0, 123.456, false);
let number = ieee754.read(view, 0, false, 52, 8);

Other packages similar to @xtuc/ieee754

Keywords

FAQs

Package last updated on 19 Jul 2018

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc