JSFiddle - React, Tailwind, and code Playground
JavaScript
/**
SCROLL DOWN RIGHT TO THE END TO SEE USAGE
**/
/*
JavaScript BigInteger library version 0.9
http://silentmatt.com/biginteger/
Copyright (c) 2009 Matthew Crumley <email@matthewcrumley.com>
Copyright (c) 2010,2011 by John Tobey <John.Tobey@gmail.com>
Licensed under the MIT license.
Support for arbitrary internal representation base was added by
Vitaly Magerya.
*/
/*
File: biginteger.js
Exports:
<BigInteger>
*/
(function(exports) {
"use strict";
/*
Class: BigInteger
An arbitrarily-large integer.
<BigInteger> objects should be considered immutable. None of the "built-in"
methods modify *this* or their arguments. All properties should be
considered private.
All the methods of <BigInteger> instances can be called "statically". The
static versions are convenient if you don't already have a <BigInteger>
object.
As an example, these calls are equivalent.
> BigInteger(4).multiply(5); // returns BigInteger(20);
> BigInteger.multiply(4, 5); // returns BigInteger(20);
> var a = 42;
> var a = BigInteger.toJSValue("0b101010"); // Not completely useless...
*/
var CONSTRUCT = {}; // Unique token to call "private" version of constructor
/*
Constructor: BigInteger()
Convert a value to a <BigInteger>.
Although <BigInteger()> is the constructor for <BigInteger> objects, it is
best not to call it as a constructor. If *n* is a <BigInteger> object, it is
simply returned as-is. Otherwise, <BigInteger()> is equivalent to <parse>
without a radix argument.
> var n0 = BigInteger(); // Same as <BigInteger.ZERO>
> var n1 = BigInteger("123"); // Create a new <BigInteger> with value 123
> var n2 = BigInteger(123); // Create a new <BigInteger> with value 123
> var n3 = BigInteger(n2); // Return n2, unchanged
The constructor form only takes an array and a sign. *n* must be an
array of numbers in little-endian order, where each digit is between 0
and BigInteger.base. The second parameter sets the sign: -1 for
negative, +1 for...