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

jsbi

Package Overview
Dependencies
Maintainers
3
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsbi

JSBI is a pure-JavaScript implementation of [the ECMAScript BigInt proposal](https://tc39.es/proposal-bigint/), which officially became a part of the JavaScript language in ES2020.

  • 3.2.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.8M
decreased by-19.01%
Maintainers
3
Weekly downloads
 
Created

What is jsbi?

JSBI is a pure-JavaScript implementation of the official ECMAScript BigInt proposal, which provides a way to represent whole numbers larger than 2^53 - 1, which is the largest number JavaScript can reliably represent with the Number primitive. JSBI is useful for performing arbitrary-precision arithmetic in JavaScript.

What are jsbi's main functionalities?

Arithmetic Operations

JSBI allows performing basic arithmetic operations such as addition, subtraction, multiplication, division, and finding the remainder between large integers.

const JSBI = require('jsbi');

const bigInt1 = JSBI.BigInt('123456789012345678901234567890');
const bigInt2 = JSBI.BigInt('987654321098765432109876543210');

const sum = JSBI.add(bigInt1, bigInt2);
const difference = JSBI.subtract(bigInt2, bigInt1);
const product = JSBI.multiply(bigInt1, bigInt2);
const quotient = JSBI.divide(bigInt2, bigInt1);
const remainder = JSBI.remainder(bigInt2, bigInt1);

Comparison Operations

JSBI can compare BigInt numbers to check for equality, or to see if one is greater than or less than another.

const JSBI = require('jsbi');

const bigInt1 = JSBI.BigInt('1234567890');
const bigInt2 = JSBI.BigInt('1234567890');
const bigInt3 = JSBI.BigInt('9876543210');

const isEqual = JSBI.equal(bigInt1, bigInt2); // true
const isLessThan = JSBI.lessThan(bigInt1, bigInt3); // true
const isGreaterThan = JSBI.greaterThan(bigInt3, bigInt1); // true

Bitwise Operations

JSBI supports bitwise operations such as AND, OR, and XOR, which are useful for manipulating large integers at the bit level.

const JSBI = require('jsbi');

const bigInt1 = JSBI.BigInt('1234567890');
const bigInt2 = JSBI.BigInt('9876543210');

const bitwiseAnd = JSBI.bitwiseAnd(bigInt1, bigInt2);
const bitwiseOr = JSBI.bitwiseOr(bigInt1, bigInt2);
const bitwiseXor = JSBI.bitwiseXor(bigInt1, bigInt2);

Other packages similar to jsbi

FAQs

Package last updated on 29 Sep 2021

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