Socket
Socket
Sign inDemoInstall

@xtuc/ieee754

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

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


Version published
Maintainers
1
Weekly downloads
17,270,061
decreased by-6.54%

Weekly downloads

Package description

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

Readme

Source

ieee754 travis npm downloads javascript style guide

saucelabs

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

install

npm install ieee754

methods

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:

  • buffer = the buffer
  • offset = offset into the buffer
  • value = value to set (only for write)
  • isLe = is little endian?
  • mLen = mantissa length
  • nBytes = number of bytes

what is ieee754?

The IEEE Standard for Floating-Point Arithmetic (IEEE 754) is a technical standard for floating-point computation. Read more.

license

BSD 3 Clause. Copyright (c) 2008, Fair Oaks Labs, Inc.

Keywords

FAQs

Last updated on 19 Jul 2018

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc