{"_id":"@afzalimdad9/big-integer","_rev":"1-2397932cc12788ed82826b410faa636a","name":"@afzalimdad9/big-integer","dist-tags":{"latest":"1.6.53"},"versions":{"1.6.52":{"name":"@afzalimdad9/big-integer","version":"1.6.52","keywords":["math","big","bignum","bigint","biginteger","integer","arbitrary","precision","arithmetic"],"author":{"name":"Afzal Imdad","email":"afzalimdad9@gmail.com"},"license":"Unlicense","_id":"@afzalimdad9/big-integer@1.6.52","maintainers":[{"name":"afzalimdad9","email":"afzalimdad9@gmail.com"}],"contributors":[],"homepage":"https://github.com/afzalimdad9/BigInteger.js#readme","bugs":{"url":"https://github.com/afzalimdad9/BigInteger.js/issues"},"dist":{"shasum":"e62965272c3b16e340668e22987fd0a9ffd2df32","tarball":"https://registry.npmjs.org/@afzalimdad9/big-integer/-/big-integer-1.6.52.tgz","fileCount":8,"integrity":"sha512-kIy4pyx8xRD3LDMQ6hpEbfq9JdIEfRGLEO+/giIs9jI/JnRw7jMUjslSgmOaDSEUaIDzvv/WmkKex5yDtKgJEA==","signatures":[{"sig":"MEUCIEtaV3H9qBLtiuIspkdQgUQ9kRSZiL/NDvvPtqBHJOKJAiEA/DFJdsTmgXMDjDtufzWhfTNjPfg9NA9Tlz/zhoyjRsk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":175034},"main":"./BigInteger","engines":{"node":">=0.6"},"gitHead":"8dcc208f0850e234bd4caf95d8489a8067b52f9f","scripts":{"test":"tsc && karma start my.conf.js && node spec/tsDefinitions.js","minify":"uglifyjs BigInteger.js -o BigInteger.min.js"},"typings":"./BigInteger.d.ts","_npmUser":{"name":"afzalimdad9","email":"afzalimdad9@gmail.com"},"repository":{"url":"git+https://github.com/afzalimdad9/BigInteger.js.git","type":"git"},"_npmVersion":"10.8.2","description":"An arbitrary length integer library for Javascript","directories":{},"_nodeVersion":"18.20.5","_hasShrinkwrap":false,"devDependencies":{"karma":"^6.3.4","lodash":"^4.17.21","jasmine":"3.5.0","coveralls":"^3.0.6","karma-cli":"^2.0.0","uglify-js":"^3.17.4","typescript":"^5.3.2","@types/node":"^7.10.2","jasmine-core":"^3.5.0","@types/lodash":"^4.14.175","karma-jasmine":"^4.0.1","karma-coverage":"^2.0.3","karma-phantomjs-launcher":"^1.0.4"},"_npmOperationalInternal":{"tmp":"tmp/big-integer_1.6.52_1737055865452_0.010411990756044709","host":"s3://npm-registry-packages-npm-production"}},"1.6.53":{"name":"@afzalimdad9/big-integer","version":"1.6.53","author":{"name":"Afzal Imdad","email":"afzalimdad9@gmail.com"},"description":"An arbitrary length integer library for Javascript","contributors":[],"scripts":{"test":"tsc && karma start my.conf.js && node spec/tsDefinitions.js","minify":"uglifyjs BigInteger.js -o BigInteger.min.js"},"main":"./BigInteger","repository":{"type":"git","url":"git+https://github.com/afzalimdad9/BigInteger.js.git"},"keywords":["math","big","bignum","bigint","biginteger","integer","arbitrary","precision","arithmetic"],"devDependencies":{"@types/lodash":"^4.14.175","@types/node":"^7.10.2","coveralls":"^3.0.6","jasmine":"3.5.0","jasmine-core":"^3.5.0","karma":"^6.3.4","karma-cli":"^2.0.0","karma-coverage":"^2.0.3","karma-jasmine":"^4.0.1","karma-phantomjs-launcher":"^1.0.4","lodash":"^4.17.21","typescript":"^5.3.2","uglify-js":"^3.17.4"},"license":"Unlicense","engines":{"node":">=0.6"},"typings":"./BigInteger.d.ts","_id":"@afzalimdad9/big-integer@1.6.53","gitHead":"2bd96c67b7f34d6cdc615c1a0c85a5c52f73fc02","bugs":{"url":"https://github.com/afzalimdad9/BigInteger.js/issues"},"homepage":"https://github.com/afzalimdad9/BigInteger.js#readme","_nodeVersion":"18.20.5","_npmVersion":"10.8.2","dist":{"integrity":"sha512-iWyQ80dKuFJtgPZh8xuIhXgAcOrWYh0CEwUaSk1ItG9DAwof/P7z2L+XqE9fIYHsnCRIa/N1SHzXQcYV6XuFhg==","shasum":"4de865513cea9ae649c4cb976271726890f75169","tarball":"https://registry.npmjs.org/@afzalimdad9/big-integer/-/big-integer-1.6.53.tgz","fileCount":8,"unpackedSize":175086,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDWrTubCGEc/EansncSjNNkSi1DTgbUqR+8tKbk5RVQuAiEAuSCiWhScjvudmg6pDRp0dLEauQhrcBpcwn47+DCvhns="}]},"_npmUser":{"name":"afzalimdad9","email":"afzalimdad9@gmail.com"},"directories":{},"maintainers":[{"name":"afzalimdad9","email":"afzalimdad9@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/big-integer_1.6.53_1737056750902_0.9663917812675229"},"_hasShrinkwrap":false}},"time":{"created":"2025-01-16T19:31:05.324Z","modified":"2025-01-16T19:45:51.312Z","1.6.52":"2025-01-16T19:31:05.655Z","1.6.53":"2025-01-16T19:45:51.125Z"},"bugs":{"url":"https://github.com/afzalimdad9/BigInteger.js/issues"},"author":{"name":"Afzal Imdad","email":"afzalimdad9@gmail.com"},"license":"Unlicense","homepage":"https://github.com/afzalimdad9/BigInteger.js#readme","keywords":["math","big","bignum","bigint","biginteger","integer","arbitrary","precision","arithmetic"],"repository":{"type":"git","url":"git+https://github.com/afzalimdad9/BigInteger.js.git"},"description":"An arbitrary length integer library for Javascript","contributors":[],"maintainers":[{"name":"afzalimdad9","email":"afzalimdad9@gmail.com"}],"readme":"# BigInteger.js [![Build Status][travis-img]][travis-url] [![Coverage Status][coveralls-img]][coveralls-url] [![Monthly Downloads][downloads-img]][downloads-url]\r\n\r\n[travis-url]: https://travis-ci.org/afzalimdad9/BigInteger.js\r\n[travis-img]: https://travis-ci.org/afzalimdad9/BigInteger.js.svg?branch=master\r\n[coveralls-url]: https://coveralls.io/github/afzalimdad9/BigInteger.js?branch=master\r\n[coveralls-img]: https://coveralls.io/repos/afzalimdad9/BigInteger.js/badge.svg?branch=master&service=github\r\n[downloads-url]: https://www.npmjs.com/package/@afzalimdad9/big-integer\r\n[downloads-img]: https://img.shields.io/npm/dm/@afzalimdad9/big-integer.svg\r\n\r\n**BigInteger.js** is an arbitrary-length integer library for Javascript, allowing arithmetic operations on integers of unlimited size, notwithstanding memory and time limitations.\r\n\r\n**Update (December 2, 2018):** [`BigInt` is being added as a native feature of JavaScript](https://tc39.github.io/proposal-bigint/). This library now works as a polyfill: if the environment supports the native `BigInt`, this library acts as a thin wrapper over the native implementation.\r\n\r\n## Installation\r\n\r\nIf you are using a browser, you can download [BigInteger.js from GitHub](http://afzalimdad9.github.com/BigInteger.js/BigInteger.min.js) or just hotlink to it:\r\n\r\n\t<script src=\"https://afzalimdad9.github.io/BigInteger.js/BigInteger.min.js\"></script>\r\n\r\nIf you are using node, you can install BigInteger with [npm](https://npmjs.org/).\r\n\r\n    npm install @afzalimdad9/big-integer\r\n\r\nThen you can include it in your code:\r\n\r\n\tvar bigInt = require(\"@afzalimdad9/big-integer\");\r\n\r\n\r\n## Usage\r\n### `bigInt(number, [base], [alphabet], [caseSensitive])`\r\n\r\nYou can create a bigInt by calling the `bigInt` function. You can pass in\r\n\r\n - a string, which it will parse as an bigInt and throw an `\"Invalid integer\"` error if the parsing fails.\r\n - a Javascript number, which it will parse as an bigInt and throw an `\"Invalid integer\"` error if the parsing fails.\r\n - another bigInt.\r\n - nothing, and it will return `bigInt.zero`.\r\n\r\n If you provide a second parameter, then it will parse `number` as a number in base `base`. Note that `base` can be any bigInt (even negative or zero). The letters \"a-z\" and \"A-Z\" will be interpreted as the numbers 10 to 35. Higher digits can be specified in angle brackets (`<` and `>`). The default `base` is `10`.\r\n\r\n You can specify a custom alphabet for base conversion with the third parameter. The default `alphabet` is `\"0123456789abcdefghijklmnopqrstuvwxyz\"`.\r\n\r\n The fourth parameter specifies whether or not the number string should be case-sensitive, i.e. whether `a` and `A` should be treated as different digits. By default `caseSensitive` is `false`.\r\n\r\nExamples:\r\n\r\n    var zero = bigInt();\r\n    var ninetyThree = bigInt(93);\r\n\tvar largeNumber = bigInt(\"75643564363473453456342378564387956906736546456235345\");\r\n\tvar googol = bigInt(\"1e100\");\r\n\tvar bigNumber = bigInt(largeNumber);\r\n\r\n\tvar maximumByte = bigInt(\"FF\", 16);\r\n\tvar fiftyFiveGoogol = bigInt(\"<55>0\", googol);\r\n\r\nNote that Javascript numbers larger than `9007199254740992` and smaller than `-9007199254740992` are not precisely represented numbers and will not produce exact results. If you are dealing with numbers outside that range, it is better to pass in strings.\r\n\r\n### Method Chaining\r\n\r\nNote that bigInt operations return bigInts, which allows you to chain methods, for example:\r\n\r\n    var salary = bigInt(dollarsPerHour).times(hoursWorked).plus(randomBonuses)\r\n\r\n### Constants\r\n\r\nThere are three named constants already stored that you do not have to construct with the `bigInt` function yourself:\r\n\r\n - `bigInt.one`, equivalent to `bigInt(1)`\r\n - `bigInt.zero`, equivalent to `bigInt(0)`\r\n - `bigInt.minusOne`, equivalent to `bigInt(-1)`\r\n\r\nThe numbers from -999 to 999 are also already prestored and can be accessed using `bigInt[index]`, for example:\r\n\r\n - `bigInt[-999]`, equivalent to `bigInt(-999)`\r\n - `bigInt[256]`, equivalent to `bigInt(256)`\r\n\r\n### Methods\r\n\r\n#### `abs()`\r\n\r\nReturns the absolute value of a bigInt.\r\n\r\n - `bigInt(-45).abs()` => `45`\r\n - `bigInt(45).abs()` => `45`\r\n\r\n#### `add(number)`\r\n\r\nPerforms addition.\r\n\r\n - `bigInt(5).add(7)` => `12`\r\n\r\n[View benchmarks for this method](http://afzalimdad9.github.io/BigInteger.js/benchmark/#Addition)\r\n\r\n#### `and(number)`\r\n\r\nPerforms the bitwise AND operation. The operands are treated as if they were represented using [two's complement representation](http://en.wikipedia.org/wiki/Two%27s_complement).\r\n\r\n - `bigInt(6).and(3)` => `2`\r\n - `bigInt(6).and(-3)` => `4`\r\n\r\n#### `bitLength()`\r\n\r\nReturns the number of digits required to represent a bigInt in binary.\r\n\r\n - `bigInt(5)` => `3` (since 5 is `101` in binary, which is three digits long)\r\n\r\n#### `compare(number)`\r\n\r\nPerforms a comparison between two numbers. If the numbers are equal, it returns `0`. If the first number is greater, it returns `1`. If the first number is lesser, it returns `-1`.\r\n\r\n - `bigInt(5).compare(5)` => `0`\r\n - `bigInt(5).compare(4)` => `1`\r\n - `bigInt(4).compare(5)` => `-1`\r\n\r\n#### `compareAbs(number)`\r\n\r\nPerforms a comparison between the absolute value of two numbers.\r\n\r\n - `bigInt(5).compareAbs(-5)` => `0`\r\n - `bigInt(5).compareAbs(4)` => `1`\r\n - `bigInt(4).compareAbs(-5)` => `-1`\r\n\r\n#### `compareTo(number)`\r\n\r\nAlias for the `compare` method.\r\n\r\n#### `divide(number)`\r\n\r\nPerforms integer division, disregarding the remainder.\r\n\r\n - `bigInt(59).divide(5)` => `11`\r\n\r\n[View benchmarks for this method](http://afzalimdad9.github.io/BigInteger.js/benchmark/#Division)\r\n\r\n#### `divmod(number)`\r\n\r\nPerforms division and returns an object with two properties: `quotient` and `remainder`. The sign of the remainder will match the sign of the dividend.\r\n\r\n - `bigInt(59).divmod(5)` => `{quotient: bigInt(11), remainder: bigInt(4) }`\r\n - `bigInt(-5).divmod(2)` => `{quotient: bigInt(-2), remainder: bigInt(-1) }`\r\n\r\n[View benchmarks for this method](http://afzalimdad9.github.io/BigInteger.js/benchmark/#Division)\r\n\r\n#### `eq(number)`\r\n\r\nAlias for the `equals` method.\r\n\r\n#### `equals(number)`\r\n\r\nChecks if two numbers are equal.\r\n\r\n - `bigInt(5).equals(5)` => `true`\r\n - `bigInt(4).equals(7)` => `false`\r\n\r\n#### `geq(number)`\r\n\r\nAlias for the `greaterOrEquals` method.\r\n\r\n\r\n#### `greater(number)`\r\n\r\nChecks if the first number is greater than the second.\r\n\r\n - `bigInt(5).greater(6)` => `false`\r\n - `bigInt(5).greater(5)` => `false`\r\n - `bigInt(5).greater(4)` => `true`\r\n\r\n#### `greaterOrEquals(number)`\r\n\r\nChecks if the first number is greater than or equal to the second.\r\n\r\n - `bigInt(5).greaterOrEquals(6)` => `false`\r\n - `bigInt(5).greaterOrEquals(5)` => `true`\r\n - `bigInt(5).greaterOrEquals(4)` => `true`\r\n\r\n#### `gt(number)`\r\n\r\nAlias for the `greater` method.\r\n\r\n#### `isDivisibleBy(number)`\r\n\r\nReturns `true` if the first number is divisible by the second number, `false` otherwise.\r\n\r\n - `bigInt(999).isDivisibleBy(333)` => `true`\r\n - `bigInt(99).isDivisibleBy(5)` => `false`\r\n\r\n#### `isEven()`\r\n\r\nReturns `true` if the number is even, `false` otherwise.\r\n\r\n - `bigInt(6).isEven()` => `true`\r\n - `bigInt(3).isEven()` => `false`\r\n\r\n#### `isNegative()`\r\n\r\nReturns `true` if the number is negative, `false` otherwise.\r\nReturns `false` for `0` and `-0`.\r\n\r\n - `bigInt(-23).isNegative()` => `true`\r\n - `bigInt(50).isNegative()` => `false`\r\n\r\n#### `isOdd()`\r\n\r\nReturns `true` if the number is odd, `false` otherwise.\r\n\r\n - `bigInt(13).isOdd()` => `true`\r\n - `bigInt(40).isOdd()` => `false`\r\n\r\n#### `isPositive()`\r\n\r\nReturn `true` if the number is positive, `false` otherwise.\r\nReturns `false` for `0` and `-0`.\r\n\r\n - `bigInt(54).isPositive()` => `true`\r\n - `bigInt(-1).isPositive()` => `false`\r\n\r\n#### `isPrime(strict?)`\r\n\r\nReturns `true` if the number is prime, `false` otherwise.\r\nSet \"strict\" boolean to true to force GRH-supported lower bound of 2*log(N)^2.\r\n\r\n - `bigInt(5).isPrime()` => `true`\r\n - `bigInt(6).isPrime()` => `false`\r\n\r\n#### `isProbablePrime([iterations], [rng])`\r\n\r\nReturns `true` if the number is very likely to be prime, `false` otherwise.\r\nSupplying `iterations` is optional - it determines the number of iterations of the test (default: `5`). The more iterations, the lower chance of getting a false positive.\r\nThis uses the [Miller Rabin test](https://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test).\r\n\r\n - `bigInt(5).isProbablePrime()` => `true`\r\n - `bigInt(49).isProbablePrime()` => `false`\r\n - `bigInt(1729).isProbablePrime()` => `false`\r\n\r\nNote that this function is not deterministic, since it relies on random sampling of factors, so the result for some numbers is not always the same - unless you pass a predictable random number generator as `rng`. The behavior and requirements are the same as with `randBetween`.\r\n\r\n - `bigInt(1729).isProbablePrime(1, () => 0.1)` => `false`\r\n - `bigInt(1729).isProbablePrime(1, () => 0.2)` => `true`\r\n\r\nIf the number is composite then the Miller–Rabin primality test declares the number probably prime with a probability at most `4` to the power `−iterations`.\r\nIf the number is prime, this function always returns `true`.\r\n\r\n#### `isUnit()`\r\n\r\nReturns `true` if the number is `1` or `-1`, `false` otherwise.\r\n\r\n - `bigInt.one.isUnit()` => `true`\r\n - `bigInt.minusOne.isUnit()` => `true`\r\n - `bigInt(5).isUnit()` => `false`\r\n\r\n#### `isZero()`\r\n\r\nReturn `true` if the number is `0` or `-0`, `false` otherwise.\r\n\r\n - `bigInt.zero.isZero()` => `true`\r\n - `bigInt(\"-0\").isZero()` => `true`\r\n - `bigInt(50).isZero()` => `false`\r\n\r\n#### `leq(number)`\r\n\r\nAlias for the `lesserOrEquals` method.\r\n\r\n#### `lesser(number)`\r\n\r\nChecks if the first number is lesser than the second.\r\n\r\n - `bigInt(5).lesser(6)` => `true`\r\n - `bigInt(5).lesser(5)` => `false`\r\n - `bigInt(5).lesser(4)` => `false`\r\n\r\n#### `lesserOrEquals(number)`\r\n\r\nChecks if the first number is less than or equal to the second.\r\n\r\n - `bigInt(5).lesserOrEquals(6)` => `true`\r\n - `bigInt(5).lesserOrEquals(5)` => `true`\r\n - `bigInt(5).lesserOrEquals(4)` => `false`\r\n\r\n#### `lt(number)`\r\n\r\nAlias for the `lesser` method.\r\n\r\n#### `minus(number)`\r\n\r\nAlias for the `subtract` method.\r\n\r\n - `bigInt(3).minus(5)` => `-2`\r\n\r\n[View benchmarks for this method](http://afzalimdad9.github.io/BigInteger.js/benchmark/#Subtraction)\r\n\r\n#### `mod(number)`\r\n\r\nPerforms division and returns the remainder, disregarding the quotient. The sign of the remainder will match the sign of the dividend.\r\n\r\n - `bigInt(59).mod(5)` =>  `4`\r\n - `bigInt(-5).mod(2)` => `-1`\r\n\r\n[View benchmarks for this method](http://afzalimdad9.github.io/BigInteger.js/benchmark/#Division)\r\n\r\n#### `modInv(mod)`\r\n\r\nFinds the [multiplicative inverse](https://en.wikipedia.org/wiki/Modular_multiplicative_inverse) of the number modulo `mod`.\r\n\r\n - `bigInt(3).modInv(11)` => `4`\r\n - `bigInt(42).modInv(2017)` => `1969`\r\n\r\n#### `modPow(exp, mod)`\r\n\r\nTakes the number to the power `exp` modulo `mod`.\r\n\r\n - `bigInt(10).modPow(3, 30)` => `10`\r\n\r\n#### `multiply(number)`\r\n\r\nPerforms multiplication.\r\n\r\n - `bigInt(111).multiply(111)` => `12321`\r\n\r\n[View benchmarks for this method](http://afzalimdad9.github.io/BigInteger.js/benchmark/#Multiplication)\r\n\r\n#### `neq(number)`\r\n\r\nAlias for the `notEquals` method.\r\n\r\n#### `next()`\r\n\r\nAdds one to the number.\r\n\r\n - `bigInt(6).next()` => `7`\r\n\r\n#### `not()`\r\n\r\nPerforms the bitwise NOT operation. The operands are treated as if they were represented using [two's complement representation](http://en.wikipedia.org/wiki/Two%27s_complement).\r\n\r\n - `bigInt(10).not()` => `-11`\r\n - `bigInt(0).not()` => `-1`\r\n\r\n#### `notEquals(number)`\r\n\r\nChecks if two numbers are not equal.\r\n\r\n - `bigInt(5).notEquals(5)` => `false`\r\n - `bigInt(4).notEquals(7)` => `true`\r\n\r\n#### `or(number)`\r\n\r\nPerforms the bitwise OR operation. The operands are treated as if they were represented using [two's complement representation](http://en.wikipedia.org/wiki/Two%27s_complement).\r\n\r\n - `bigInt(13).or(10)` => `15`\r\n - `bigInt(13).or(-8)` => `-3`\r\n\r\n#### `over(number)`\r\n\r\nAlias for the `divide` method.\r\n\r\n - `bigInt(59).over(5)` => `11`\r\n\r\n[View benchmarks for this method](http://afzalimdad9.github.io/BigInteger.js/benchmark/#Division)\r\n\r\n#### `plus(number)`\r\n\r\nAlias for the `add` method.\r\n\r\n - `bigInt(5).plus(7)` => `12`\r\n\r\n[View benchmarks for this method](http://afzalimdad9.github.io/BigInteger.js/benchmark/#Addition)\r\n\r\n#### `pow(number)`\r\n\r\nPerforms exponentiation. If the exponent is less than `0`, `pow` returns `0`. `bigInt.zero.pow(0)` returns `1`.\r\n\r\n - `bigInt(16).pow(16)` => `18446744073709551616`\r\n\r\n[View benchmarks for this method](http://afzalimdad9.github.io/BigInteger.js/benchmark/#Exponentiation)\r\n\r\n#### `prev(number)`\r\n\r\nSubtracts one from the number.\r\n\r\n - `bigInt(6).prev()` => `5`\r\n\r\n#### `remainder(number)`\r\n\r\nAlias for the `mod` method.\r\n\r\n[View benchmarks for this method](http://afzalimdad9.github.io/BigInteger.js/benchmark/#Division)\r\n\r\n#### `shiftLeft(n)`\r\n\r\nShifts the number left by `n` places in its binary representation. If a negative number is provided, it will shift right. Throws an error if `n` is outside of the range `[-9007199254740992, 9007199254740992]`.\r\n\r\n - `bigInt(8).shiftLeft(2)` => `32`\r\n - `bigInt(8).shiftLeft(-2)` => `2`\r\n\r\n#### `shiftRight(n)`\r\n\r\nShifts the number right by `n` places in its binary representation. If a negative number is provided, it will shift left. Throws an error if `n` is outside of the range `[-9007199254740992, 9007199254740992]`.\r\n\r\n - `bigInt(8).shiftRight(2)` => `2`\r\n - `bigInt(8).shiftRight(-2)` => `32`\r\n\r\n#### `square()`\r\n\r\nSquares the number\r\n\r\n - `bigInt(3).square()` => `9`\r\n\r\n[View benchmarks for this method](http://afzalimdad9.github.io/BigInteger.js/benchmark/#Squaring)\r\n\r\n#### `subtract(number)`\r\n\r\nPerforms subtraction.\r\n\r\n - `bigInt(3).subtract(5)` => `-2`\r\n\r\n[View benchmarks for this method](http://afzalimdad9.github.io/BigInteger.js/benchmark/#Subtraction)\r\n\r\n#### `times(number)`\r\n\r\nAlias for the `multiply` method.\r\n\r\n - `bigInt(111).times(111)` => `12321`\r\n\r\n[View benchmarks for this method](http://afzalimdad9.github.io/BigInteger.js/benchmark/#Multiplication)\r\n\r\n#### `toArray(radix)`\r\n\r\nConverts a bigInt into an object with the properties \"value\" and \"isNegative.\" \"Value\" is an array of integers modulo the given radix. \"isNegative\" is a boolean that represents the sign of the result.\r\n\r\n - `bigInt(\"1e9\").toArray(10)` => {\r\n     value: [1, 0, 0, 0, 0, 0, 0, 0, 0, 0],\r\n     isNegative: false\r\n   }\r\n - `bigInt(\"1e9\").toArray(16)` => {\r\n     value: [3, 11, 9, 10, 12, 10, 0, 0],\r\n     isNegative: false\r\n   }\r\n - `bigInt(567890).toArray(100)` => {\r\n     value: [56, 78, 90],\r\n     isNegative: false\r\n   }\r\n\r\nNegative bases are supported.\r\n\r\n - `bigInt(12345).toArray(-10)` => {\r\n     value: [2, 8, 4, 6, 5],\r\n     isNegative: false\r\n   }\r\n\r\nBase 1 and base -1 are also supported.\r\n\r\n - `bigInt(-15).toArray(1)` => {\r\n     value: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],\r\n     isNegative: true\r\n   }\r\n - `bigInt(-15).toArray(-1)` => {\r\n     value: [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,\r\n             0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],\r\n     isNegative: false\r\n   }\r\n\r\nBase 0 is only allowed for the number zero.\r\n\r\n - `bigInt(0).toArray(0)` => {\r\n     value: [0],\r\n     isNegative: false\r\n   }\r\n - `bigInt(1).toArray(0)` => `Error: Cannot convert nonzero numbers to base 0.`\r\n\r\n#### `toJSNumber()`\r\n\r\nConverts a bigInt into a native Javascript number. Loses precision for numbers outside the range `[-9007199254740992, 9007199254740992]`.\r\n\r\n - `bigInt(\"18446744073709551616\").toJSNumber()` => `18446744073709552000`\r\n\r\n#### `xor(number)`\r\n\r\nPerforms the bitwise XOR operation. The operands are treated as if they were represented using [two's complement representation](http://en.wikipedia.org/wiki/Two%27s_complement).\r\n\r\n - `bigInt(12).xor(5)` => `9`\r\n - `bigInt(12).xor(-5)` => `-9`\r\n\r\n### Static Methods\r\n\r\n#### `fromArray(digits, base = 10, isNegative?)`\r\n\r\nConstructs a bigInt from an array of digits in base `base`. The optional `isNegative` flag will make the number negative.\r\n\r\n - `bigInt.fromArray([1, 2, 3, 4, 5], 10)` => `12345`\r\n - `bigInt.fromArray([1, 0, 0], 2, true)` => `-4`\r\n\r\n#### `gcd(a, b)`\r\n\r\nFinds the greatest common denominator of `a` and `b`.\r\n\r\n - `bigInt.gcd(42,56)` => `14`\r\n\r\n#### `isInstance(x)`\r\n\r\nReturns `true` if `x` is a BigInteger, `false` otherwise.\r\n\r\n - `bigInt.isInstance(bigInt(14))` => `true`\r\n - `bigInt.isInstance(14)` => `false`\r\n\r\n#### `lcm(a,b)`\r\n\r\nFinds the least common multiple of `a` and `b`.\r\n\r\n - `bigInt.lcm(21, 6)` => `42`\r\n\r\n#### `max(a,b)`\r\n\r\nReturns the largest of `a` and `b`.\r\n\r\n - `bigInt.max(77, 432)` => `432`\r\n\r\n#### `min(a,b)`\r\n\r\nReturns the smallest of `a` and `b`.\r\n\r\n - `bigInt.min(77, 432)` => `77`\r\n\r\n#### `randBetween(min, max, [rng])`\r\n\r\nReturns a random number between `min` and `max`, optionally using `rng` to generate randomness.\r\n\r\n - `bigInt.randBetween(\"-1e100\", \"1e100\")` => (for example) `8494907165436643479673097939554427056789510374838494147955756275846226209006506706784609314471378745`\r\n\r\n`rng` should take no arguments and return a `number` between 0 and 1. It defaults to `Math.random`.\r\n\r\n  - `bigInt.randBetween(\"-1e100\", \"1e100\", () => 0.5)` => (always) `50000005000000500000050000005000000500000050000005000000500000050000005000000500000050000005000000`\r\n\r\n\r\n### Override Methods\r\n\r\n#### `toString(radix = 10, [alphabet])`\r\n\r\nConverts a bigInt to a string. There is an optional radix parameter (which defaults to 10) that converts the number to the given radix. Digits in the range `10-35` will use the letters `a-z`.\r\n\r\n - `bigInt(\"1e9\").toString()` => `\"1000000000\"`\r\n - `bigInt(\"1e9\").toString(16)` => `\"3b9aca00\"`\r\n\r\n You can use a custom base alphabet with the second parameter. The default `alphabet` is `\"0123456789abcdefghijklmnopqrstuvwxyz\"`.\r\n\r\n  - `bigInt(\"5\").toString(2, \"aA\")` => `\"AaA\"`\r\n\r\n**Note that arithmetical operators will trigger the `valueOf` function rather than the `toString` function.** When converting a bigInteger to a string, you should use the `toString` method or the `String` function instead of adding the empty string.\r\n\r\n - `bigInt(\"999999999999999999\").toString()` => `\"999999999999999999\"`\r\n - `String(bigInt(\"999999999999999999\"))` => `\"999999999999999999\"`\r\n - `bigInt(\"999999999999999999\") + \"\"` => `1000000000000000000`\r\n\r\nBases larger than 36 are supported. If a digit is greater than or equal to 36, it will be enclosed in angle brackets.\r\n\r\n - `bigInt(567890).toString(100)` => `\"<56><78><90>\"`\r\n\r\nNegative bases are also supported.\r\n\r\n - `bigInt(12345).toString(-10)` => `\"28465\"`\r\n\r\nBase 1 and base -1 are also supported.\r\n\r\n - `bigInt(-15).toString(1)` => `\"-111111111111111\"`\r\n - `bigInt(-15).toString(-1)` => `\"101010101010101010101010101010\"`\r\n\r\nBase 0 is only allowed for the number zero.\r\n\r\n - `bigInt(0).toString(0)` => `0`\r\n - `bigInt(1).toString(0)` => `Error: Cannot convert nonzero numbers to base 0.`\r\n\r\n[View benchmarks for this method](http://afzalimdad9.github.io/BigInteger.js/benchmark/#toString)\r\n\r\n#### `valueOf()`\r\n\r\nConverts a bigInt to a native Javascript number. This override allows you to use native arithmetic operators without explicit conversion:\r\n\r\n - `bigInt(\"100\") + bigInt(\"200\") === 300; //true`\r\n\r\n## Contributors\r\n\r\nTo contribute, just fork the project, make some changes, and submit a pull request. Please verify that the unit tests pass before submitting.\r\n\r\nThe unit tests are contained in the `spec/spec.js` file. You can run them locally by opening the `spec/SpecRunner.html` or file or running `npm test`. You can also [run the tests online from GitHub](http://afzalimdad9.github.io/BigInteger.js/spec/SpecRunner.html).\r\n\r\nThere are performance benchmarks that can be viewed from the `benchmarks/index.html` page. You can [run them online from GitHub](http://afzalimdad9.github.io/BigInteger.js/benchmark/).\r\n\r\n## License\r\n\r\nThis project is public domain. For more details, read about the [Unlicense](http://unlicense.org/).\r\n","readmeFilename":"README.md"}