# .css-1ydg16i{color:#000;-webkit-text-decoration:none;text-decoration:none;}UNPKG

 1 ```/** ``` 2 ``` * Check if value is a bigint. ``` 3 ``` * [š](https://github.com/nodef/extra-bigint/wiki/is) ``` 4 ``` * @param x a value ``` 5 ``` * @returns is bigint? ``` 6 ``` */ ``` 7 ```declare function is(x: any): x is bigint; ``` 8 ```/** ``` 9 ``` * Compare two bigints. ``` 10 ``` * [š](https://github.com/nodef/extra-bigint/wiki/compare) ``` 11 ``` * @param x a bigint ``` 12 ``` * @param y another bigint ``` 13 ``` * @returns xy: +ve ``` 14 ``` */ ``` 15 ```declare function compare(x: bigint, y: bigint): number; ``` 16 ```/** ``` 17 ``` * Get the absolute of a bigint. ``` 18 ``` * [š](https://github.com/nodef/extra-bigint/wiki/abs) ``` 19 ``` * @param x a bigint ``` 20 ``` * @returns |x| ``` 21 ``` */ ``` 22 ```declare function abs(x: bigint): bigint; ``` 23 ```/** ``` 24 ``` * Get the sign of a bigint. ``` 25 ``` * [š](https://github.com/nodef/extra-bigint/wiki/sign) ``` 26 ``` * @param x a bigint ``` 27 ``` * @returns x>0: 1n, x<0: -1n, x=0: 0n ``` 28 ``` */ ``` 29 ```declare function sign(x: bigint): bigint; ``` 30 ```/** ``` 31 ``` * Perform floor-divison of two bigints (\\). ``` 32 ``` * [š](https://github.com/nodef/extra-bigint/wiki/floorDiv) ``` 33 ``` * @param x dividend ``` 34 ``` * @param y divisor ``` 35 ``` * @returns āx/yā ``` 36 ``` */ ``` 37 ```declare function floorDiv(x: bigint, y: bigint): bigint; ``` 38 ```/** ``` 39 ``` * Perform ceiling-divison of two bigints. ``` 40 ``` * [š](https://github.com/nodef/extra-bigint/wiki/ceilDiv) ``` 41 ``` * @param x dividend ``` 42 ``` * @param y divisor ``` 43 ``` * @returns āx/yā ``` 44 ``` */ ``` 45 ```declare function ceilDiv(x: bigint, y: bigint): bigint; ``` 46 ```/** ``` 47 ``` * Perform rounded-divison of two bigints. ``` 48 ``` * [š](https://github.com/nodef/extra-bigint/wiki/roundDiv) ``` 49 ``` * @param x divisor ``` 50 ``` * @param y dividend ``` 51 ``` * @returns [x/y] ``` 52 ``` */ ``` 53 ```declare function roundDiv(x: bigint, y: bigint): bigint; ``` 54 ```/** ``` 55 ``` * Find the remainder of x/y with sign of x (truncated division). ``` 56 ``` * [š](https://github.com/nodef/extra-bigint/wiki/rem) ``` 57 ``` * @param x dividend ``` 58 ``` * @param y divisor ``` 59 ``` * @returns trunc(x % y) ``` 60 ``` */ ``` 61 ```declare function rem(x: bigint, y: bigint): bigint; ``` 62 ```/** ``` 63 ``` * Find the remainder of x/y with sign of y (floored division). ``` 64 ``` * [š](https://github.com/nodef/extra-bigint/wiki/mod) ``` 65 ``` * @param x dividend ``` 66 ``` * @param y divisor ``` 67 ``` * @returns floor(x % y) ``` 68 ``` */ ``` 69 ```declare function mod(x: bigint, y: bigint): bigint; ``` 70 ```/** ``` 71 ``` * Find the remainder of x/y with +ve sign (euclidean division). ``` 72 ``` * [š](https://github.com/nodef/extra-bigint/wiki/modp) ``` 73 ``` * @param x dividend ``` 74 ``` * @param y divisor ``` 75 ``` * @returns x/y>0: floor(x % y), x/y<0: ceil(x % y) ``` 76 ``` */ ``` 77 ```declare function modp(x: bigint, y: bigint): bigint; ``` 78 ```/** ``` 79 ``` * Constrain a bigint within a minimum and a maximum value. ``` 80 ``` * [š](https://github.com/nodef/extra-bigint/wiki/constrain) ``` 81 ``` * @param x a bigint ``` 82 ``` * @param minv minimum value ``` 83 ``` * @param maxv maximum value ``` 84 ``` * @returns xmax: max, x ``` 85 ``` */ ``` 86 ```declare function constrain(x: bigint, minv: bigint, maxv: bigint): bigint; ``` 87 ``` ``` 88 ```/** ``` 89 ``` * Re-map a bigint from one range to another. ``` 90 ``` * [š](https://github.com/nodef/extra-bigint/wiki/remap) ``` 91 ``` * @param x a bigint ``` 92 ``` * @param r lower bound of current range ``` 93 ``` * @param R upper bound of current range ``` 94 ``` * @param t lower bound of target range ``` 95 ``` * @param T upper bound of target range ``` 96 ``` * @returns ā [ymin, ymax] ``` 97 ``` */ ``` 98 ```declare function remap(x: bigint, r: bigint, R: bigint, t: bigint, T: bigint): bigint; ``` 99 ``` ``` 100 ```/** ``` 101 ``` * Linearly interpolate a bigint between two bigints. ``` 102 ``` * [š](https://github.com/nodef/extra-bigint/wiki/lerp) ``` 103 ``` * @param x start bigint ``` 104 ``` * @param y stop bigint ``` 105 ``` * @param t interpolant ā [0, 1] ``` 106 ``` * @returns ā [x, y] ``` 107 ``` */ ``` 108 ```declare function lerp(x: bigint, y: bigint, t: number): bigint; ``` 109 ```/** ``` 110 ``` * Check if bigint is a power-of-2. ``` 111 ``` * [š](https://github.com/nodef/extra-bigint/wiki/isPow2) ``` 112 ``` * @param x a bigint ``` 113 ``` * @returns 2ā± = x? | i = +ve integer ``` 114 ``` */ ``` 115 ```declare function isPow2(x: bigint): boolean; ``` 116 ```/** ``` 117 ``` * Check if bigint is a power-of-10. ``` 118 ``` * [š](https://github.com/nodef/extra-bigint/wiki/isPow10) ``` 119 ``` * @param x a bigint ``` 120 ``` * @returns 10ā± = x? | i = +ve integer ``` 121 ``` */ ``` 122 ```declare function isPow10(x: bigint): boolean; ``` 123 ```/** ``` 124 ``` * Find largest power-of-2 less than or equal to given bigint. ``` 125 ``` * [š](https://github.com/nodef/extra-bigint/wiki/prevPow2) ``` 126 ``` * @param x a bigint ``` 127 ``` * @returns 2ā± | 2ā± ā¤ x and 2ā± > x/2 ``` 128 ``` */ ``` 129 ```declare function prevPow2(x: bigint): bigint; ``` 130 ```/** ``` 131 ``` * Find largest power-of-10 less than or equal to given bigint. ``` 132 ``` * [š](https://github.com/nodef/extra-bigint/wiki/prevPow10) ``` 133 ``` * @param x a bigint ``` 134 ``` * @returns 10ā± | 10ā± ā¤ x and 10ā± > x/10 ``` 135 ``` */ ``` 136 ```declare function prevPow10(x: bigint): bigint; ``` 137 ```/** ``` 138 ``` * Find smallest power-of-2 greater than or equal to given bigint. ``` 139 ``` * [š](https://github.com/nodef/extra-bigint/wiki/nextPow2) ``` 140 ``` * @param x a bigint ``` 141 ``` * @returns 2ā± | 2ā± ā„ x and 2ā± < 2x ``` 142 ``` */ ``` 143 ```declare function nextPow2(x: bigint): bigint; ``` 144 ```/** ``` 145 ``` * Find smallest power-of-10 greater than or equal to given bigint. ``` 146 ``` * [š](https://github.com/nodef/extra-bigint/wiki/nextPow10) ``` 147 ``` * @param x a bigint ``` 148 ``` * @returns 10ā± | 10ā± ā„ x and 10ā± < 10x ``` 149 ``` */ ``` 150 ```declare function nextPow10(x: bigint): bigint; ``` 151 ```/** ``` 152 ``` * Find the base-2 logarithm of a bigint. ``` 153 ``` * [š](https://github.com/nodef/extra-bigint/wiki/log2) ``` 154 ``` * @param x a bigint ``` 155 ``` * @returns logā(x) ``` 156 ``` */ ``` 157 ```declare function log2(x: bigint): bigint; ``` 158 ```/** ``` 159 ``` * Find the base-10 logarithm of a bigint. ``` 160 ``` * [š](https://github.com/nodef/extra-bigint/wiki/log10) ``` 161 ``` * @param x a bigint ``` 162 ``` * @returns logāā(x) ``` 163 ``` */ ``` 164 ```declare function log10(x: bigint): bigint; ``` 165 ```/** ``` 166 ``` * Find the square root of a bigint. ``` 167 ``` * [š](https://github.com/nodef/extra-bigint/wiki/sqrt) ``` 168 ``` * @param x a bigint ``` 169 ``` * @returns āx ``` 170 ``` */ ``` 171 ```declare function sqrt(x: bigint): bigint; ``` 172 ```/** ``` 173 ``` * Find the cube root of a bigint. ``` 174 ``` * [š](https://github.com/nodef/extra-bigint/wiki/cbrt) ``` 175 ``` * @param x a bigint ``` 176 ``` * @returns Ā³āx ``` 177 ``` */ ``` 178 ```declare function cbrt(x: bigint): bigint; ``` 179 ```/** ``` 180 ``` * Find the nth root of a bigint. ``` 181 ``` * [š](https://github.com/nodef/extra-bigint/wiki/root) ``` 182 ``` * @param x a bigint ``` 183 ``` * @param n nth root (1n) ``` 184 ``` * @returns āæāx ``` 185 ``` */ ``` 186 ```declare function root(x: bigint, n?: bigint): bigint; ``` 187 ```/** ``` 188 ``` * List all divisors of a bigint, except itself. ``` 189 ``` * [š](https://github.com/nodef/extra-bigint/wiki/properDivisors) ``` 190 ``` * @param x a bigint ``` 191 ``` * @returns proper divisors (factors) ``` 192 ``` */ ``` 193 ```declare function properDivisors(x: bigint): bigint[]; ``` 194 ``` ``` 195 ```/** ``` 196 ``` * Sum all proper divisors of a bigint. ``` 197 ``` * [š](https://github.com/nodef/extra-bigint/wiki/aliquotSum) ``` 198 ``` * @param x a bigint ``` 199 ``` * @returns Ī£dįµ¢ | dįµ¢ is a divisor of x and ā x ``` 200 ``` */ ``` 201 ```declare function aliquotSum(x: bigint): bigint; ``` 202 ```/** ``` 203 ``` * Find the least prime number which divides a bigint. ``` 204 ``` * [š](https://github.com/nodef/extra-bigint/wiki/minPrimeFactor) ``` 205 ``` * @param x a bigint ``` 206 ``` * @returns least prime factor ``` 207 ``` */ ``` 208 ```declare function minPrimeFactor(x: bigint): bigint; ``` 209 ``` ``` 210 ```/** ``` 211 ``` * Find the greatest prime number which divides a bigint. ``` 212 ``` * [š](https://github.com/nodef/extra-bigint/wiki/maxPrimeFactor) ``` 213 ``` * @param x a bigint ``` 214 ``` * @returns greatest prime factor ``` 215 ``` */ ``` 216 ```declare function maxPrimeFactor(x: bigint): bigint; ``` 217 ``` ``` 218 ```/** ``` 219 ``` * Find the prime factors of a bigint. ``` 220 ``` * [š](https://github.com/nodef/extra-bigint/wiki/primeFactors) ``` 221 ``` * @param x a bigint ``` 222 ``` * @returns [fā, fā, ...] | fįµ¢ divides x and is prime ``` 223 ``` */ ``` 224 ```declare function primeFactors(x: bigint): bigint[]; ``` 225 ```/** ``` 226 ``` * Find the prime factors and respective exponents of a bigint. ``` 227 ``` * [š](https://github.com/nodef/extra-bigint/wiki/primeExponentials) ``` 228 ``` * @param x a bigint ``` 229 ``` * @returns [[fā, eā], [fā, eā], ...] | fįµ¢ is a prime factor of x and eįµ¢ is its exponent ``` 230 ``` */ ``` 231 ```declare function primeExponentials(x: bigint): [bigint, bigint][]; ``` 232 ```/** ``` 233 ``` * Check if bigint is prime. ``` 234 ``` * [š](https://github.com/nodef/extra-bigint/wiki/isPrime) ``` 235 ``` * @param x a bigint ``` 236 ``` * @returns is divisible by 1n and itself only? ``` 237 ``` */ ``` 238 ```declare function isPrime(x: bigint): boolean; ``` 239 ```/** ``` 240 ``` * Find the greatest common divisor of bigints. ``` 241 ``` * [š](https://github.com/nodef/extra-bigint/wiki/gcd) ``` 242 ``` * @param xs a list of bigints ``` 243 ``` * @returns gcd(xā, xā, ...) ``` 244 ``` */ ``` 245 ```declare function gcd(...xs: bigint[]): bigint; ``` 246 ``` ``` 247 ```/** ``` 248 ``` * Find the least common multiple of bigints. ``` 249 ``` * [š](https://github.com/nodef/extra-bigint/wiki/lcm) ``` 250 ``` * @param xs a list of bigints ``` 251 ``` * @returns lcm(xā, xā, ...) ``` 252 ``` */ ``` 253 ```declare function lcm(...xs: bigint[]): bigint; ``` 254 ```/** ``` 255 ``` * Find the factorial of a bigint. ``` 256 ``` * [š](https://github.com/nodef/extra-bigint/wiki/factorial) ``` 257 ``` * @param n a bigint ``` 258 ``` * @param k denominator factorial [0] ``` 259 ``` * @returns P(n, k); k=0: n!, k>0: n!/k! ``` 260 ``` */ ``` 261 ```declare function factorial(n: bigint, k?: bigint): bigint; ``` 262 ```/** ``` 263 ``` * Find the number of ways to choose k elements from a set of n elements. ``` 264 ``` * [š](https://github.com/nodef/extra-bigint/wiki/binomial) ``` 265 ``` * @param n elements in source set ``` 266 ``` * @param k elements in choose set ``` 267 ``` * @returns C(n, k) ``` 268 ``` */ ``` 269 ```declare function binomial(n: bigint, k: bigint): bigint; ``` 270 ```/** ``` 271 ``` * Find the number of ways to put n objects in m bins (n=sum(kįµ¢)). ``` 272 ``` * [š](https://github.com/nodef/extra-bigint/wiki/multinomial) ``` 273 ``` * @param ks objects per bin (kįµ¢) ``` 274 ``` * @returns n!/(kā!kā!...) | n=sum(kįµ¢) ``` 275 ``` */ ``` 276 ```declare function multinomial(...ks: bigint[]): bigint; ``` 277 ```/** ``` 278 ``` * Find the length of hypotenuse. ``` 279 ``` * [š](https://github.com/nodef/extra-bigint/wiki/hypot) ``` 280 ``` * @param xs lengths of perpendicular sides (x, y, z, ...) ``` 281 ``` * @returns ā(xĀ² + yĀ² + zĀ²) ``` 282 ``` */ ``` 283 ```declare function hypot(...xs: bigint[]): bigint; ``` 284 ```/** ``` 285 ``` * Find the sum of bigints (Ī£). ``` 286 ``` * [š](https://github.com/nodef/extra-bigint/wiki/sum) ``` 287 ``` * @param xs bigints ``` 288 ``` * @returns Ī£xįµ¢ ``` 289 ``` */ ``` 290 ```declare function sum(...xs: bigint[]): bigint; ``` 291 ```/** ``` 292 ``` * Find the product of bigints (ā). ``` 293 ``` * [š](https://github.com/nodef/extra-bigint/wiki/product) ``` 294 ``` * @param xs bigints ``` 295 ``` * @returns āxįµ¢ ``` 296 ``` */ ``` 297 ```declare function product(...xs: bigint[]): bigint; ``` 298 ```/** ``` 299 ``` * Find the value separating the higher and lower halves of bigints. ``` 300 ``` * [š](https://github.com/nodef/extra-bigint/wiki/median) ``` 301 ``` * @param xs a list of bigints ``` 302 ``` * @returns xā | sort(xs) = [..., xā, ...] ``` 303 ``` */ ``` 304 ```declare function median(...xs: bigint[]): bigint; ``` 305 ```/** ``` 306 ``` * Find the values that appear most often. ``` 307 ``` * [š](https://github.com/nodef/extra-bigint/wiki/modes) ``` 308 ``` * @param xs a list of bigints ``` 309 ``` * @returns [xāā, xāā, ...] | count(xāįµ¢) ā„ count(xįµ¢) ā xįµ¢ ā xs ``` 310 ``` */ ``` 311 ```declare function modes(...xs: bigint[]): bigint[]; ``` 312 ```/** ``` 313 ``` * Find the smallest bigint. ``` 314 ``` * [š](https://github.com/nodef/extra-bigint/wiki/min) ``` 315 ``` * @param xs bigints ``` 316 ``` * @returns min(xs) ``` 317 ``` */ ``` 318 ```declare function min(...xs: bigint[]): bigint; ``` 319 ```/** ``` 320 ``` * Find the largest bigint. ``` 321 ``` * [š](https://github.com/nodef/extra-bigint/wiki/max) ``` 322 ``` * @param xs bigints ``` 323 ``` * @returns max(xs) ``` 324 ``` */ ``` 325 ```declare function max(...xs: bigint[]): bigint; ``` 326 ```/** ``` 327 ``` * Find the minimum and maximum bigint. ``` 328 ``` * [š](https://github.com/nodef/extra-bigint/wiki/range) ``` 329 ``` * @param xs bigints ``` 330 ``` * @returns [min, max] ``` 331 ``` */ ``` 332 ```declare function range(...xs: bigint[]): [bigint, bigint]; ``` 333 ```/** ``` 334 ``` * Find the mean of squared deviation of bigints from its mean. ``` 335 ``` * [š](https://github.com/nodef/extra-bigint/wiki/variance) ``` 336 ``` * @param xs a list of bigints ``` 337 ``` * @returns ĻĀ² = E[(xs - Āµ)Ā²] | Āµ = mean(xs) ``` 338 ``` */ ``` 339 ```declare function variance(...xs: bigint[]): bigint; ``` 340 ```/** ``` 341 ``` * Find the arithmetic mean of bigints (Āµ). ``` 342 ``` * [š](https://github.com/nodef/extra-bigint/wiki/arithmeticMean) ``` 343 ``` * @param xs bigints ``` 344 ``` * @returns Āµ = (Ī£xįµ¢)/n | n = size(xs) ``` 345 ``` */ ``` 346 ```declare function arithmeticMean(...xs: bigint[]): bigint; ``` 347 ``` ``` 348 ```/** ``` 349 ``` * Find the geometric mean of bigints. ``` 350 ``` * [š](https://github.com/nodef/extra-bigint/wiki/geometricMean) ``` 351 ``` * @param xs bigints ``` 352 ``` * @returns āæā(āxįµ¢) | n = size(xs) ``` 353 ``` */ ``` 354 ```declare function geometricMean(...xs: bigint[]): bigint; ``` 355 ```/** ``` 356 ``` * Find the harmonic mean of bigints. ``` 357 ``` * [š](https://github.com/nodef/extra-bigint/wiki/harmonicMean) ``` 358 ``` * @param xs bigints ``` 359 ``` * @returns n/Ī£(1/xįµ¢) | n = size(xs) ``` 360 ``` */ ``` 361 ```declare function harmonicMean(...xs: bigint[]): bigint; ``` 362 ```/** ``` 363 ``` * Find the quadriatic mean of bigints. ``` 364 ``` * [š](https://github.com/nodef/extra-bigint/wiki/quadriaticMean) ``` 365 ``` * @param xs bigints ``` 366 ``` * @returns ā(Ī£xįµ¢Ā²)/n | n = size(xs) ``` 367 ``` */ ``` 368 ```declare function quadriaticMean(...xs: bigint[]): bigint; ``` 369 ``` ``` 370 ```/** ``` 371 ``` * Find the cubic mean of bigints. ``` 372 ``` * [š](https://github.com/nodef/extra-bigint/wiki/cubicMean) ``` 373 ``` * @param xs bigints ``` 374 ``` * @returns Ā³ā(Ī£xįµ¢Ā³)/n | n = size(xs) ``` 375 ``` */ ``` 376 ```declare function cubicMean(...xs: bigint[]): bigint; ``` 377 ``` ``` 378 ```export { abs, properDivisors as aliquotParts, aliquotSum, arithmeticMean, binomial, cbrt, ceilDiv, constrain as clamp, compare, constrain, cubicMean, factorial, floorDiv, gcd, geometricMean, maxPrimeFactor as greatestPrimeFactor, harmonicMean, gcd as hcf, hypot, is, isPow10, isPow2, isPrime, lcm, minPrimeFactor as leastPrimeFactor, lerp, log10, log2, remap as map, max, maxPrimeFactor, arithmeticMean as mean, median, min, minPrimeFactor, mod, modes, modp, multinomial, nextPow10, nextPow2, prevPow10, prevPow2, primeExponentials, primeFactors, product, properDivisors, quadriaticMean, range, rem, remap, root, quadriaticMean as rootMeanSquare, roundDiv, sign, sqrt, sum, variance }; ```