Package Exports
- extra-bigint.web
Readme
A collection of functions for working with BigInts.
๐ฆ Node.js,
๐ Web,
๐ Files,
๐ฐ Docs,
๐ Wiki.
A BigInt can represent whole numbers larger than 2โตยณ - 1 (1). ES2020
introduced it as a built-in object. BigInt
enables us to represent integers
with arbitrary precision, allowing us to perform mathematical operations on
large integers (2). This package provides operations to work with sign,
perform arithmetic operations such as division and modulo, finding
roots, working with factors, finding logarithm, and performing basic
statistics including a number of means.
This package is available in Node.js and Web formats. The web format
is exposed as extra_bigint
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. |