JSPM

  • Created
  • Published
  • Downloads 24646
  • Score
    100M100P100Q141877F
  • License MIT

A BigInt can represent whole numbers larger than 2⁵³ - 1.

Package Exports

  • extra-bigint

Readme

A BigInt can represent whole numbers larger than 2⁵³ - 1.
📦 Node.js, 🌐 Web, 📜 Files, 📰 Docs, 📘 Wiki.

The bit is a basic unit of information in information theory, computing. This package includes bit twiddling hacks by Sean Eron Anderson and many others. JavaScript converts a Number (a 64-bit floating point number) to a 32-bit integer when bitwise operators (such as |) are applied. All bitwise operations are performed on 32-bit integers.

This package is available in Node.js and Web formats. The web format is exposed as extra_bit standalone variable and can be loaded from jsDelivr CDN.

Stability: Experimental.


const bigint = require('extra-bigint');
// import * as bigint from "extra-bigint";
// import * as bigint from "https://unpkg.com/extra-bigint/index.mjs"; (deno)

bigint.isPrime(113n);
// → true

bigint.floorDiv(7n, 3n);
// → 2n

bigint.sqrt(81n);
// → 9n

bigint.lcm(2n, 3n, 4n);
// → 12n

bigint.log2(8n);
// → 3n

bigint.sum(1n, 2n, 3n, 4n);
// → 10n

bigint.mean(1n, 7n, 8n);
// → 5n


Index

Property Description
is Check if value is a bigint.
isPrime Check if a bigint is prime.
compare Compare two bigints.
abs Get the absolute of a bigint.
sign Get the sign of a bigint.
floorDiv Calculate the floor division of bigints (\).
ceilDiv Calculate the floor division of bigints.
rem Find the remainder of x/y with sign of x (truncated division).
mod Find the remainder of x/y with sign of y (floored division).
modp Find the remainder of x/y with +ve sign (euclidean division).
sqrt Find the square root of a bigint.
cbrt Find the cube root of a bigint.
root Find the nth root of a bigint.
gcd Find the greatest common divisor of bigints.
lcm Find the least common multiple of bigints.
log2 Find the base-2 logarithm of a bigint.
log10 Find the base-10 logarithm of a bigint.
hypot Find the length of hypotenuse.
sum Find the sum of bigints (Σ).
product Find the product of bigints (∏).
min Find the smallest bigint.
max Find the largest bigint.
range Find the minimum and maximum bigint.
arithmeticMean Find the arithmetic mean of bigints (µ).
geometricMean Find the geometric mean of bigints.
harmonicMean Find the harmonic mean of bigints.
quadriaticMean Find the quadriatic mean of bigints.
cubicMean Find the cubic mean of bigints.