landvex: Fixar och tester klara för alla komponenter
- Datafabrik: Dockerfile fix, agentorkestrering fungerar - Vision: Identify-modell, FAISS, OCR alla testade - API: Alla 7 integrationstester passerade - Upplösare: Entitetsupplösning verifierad
This commit is contained in:
+2393
@@ -0,0 +1,2393 @@
|
||||
/**
|
||||
* Type definitions for BigInteger.js
|
||||
* Definitions by: Tommy Frazier <https://github.com/toefraz>
|
||||
*/
|
||||
export = bigInt;
|
||||
export as namespace bigInt;
|
||||
|
||||
declare var bigInt: bigInt.BigIntegerStatic;
|
||||
|
||||
declare namespace bigInt {
|
||||
type BigNumber = number | bigint | string | BigInteger;
|
||||
|
||||
interface BigIntegerStatic {
|
||||
/**
|
||||
* Equivalent to bigInt(0).
|
||||
*/
|
||||
(): BigInteger;
|
||||
|
||||
/**
|
||||
* Parse a Javascript number into a bigInt.
|
||||
*/
|
||||
(number: number): BigInteger;
|
||||
|
||||
/**
|
||||
* Parse a Javascript native bigint into a bigInt.
|
||||
*/
|
||||
(number: bigint): BigInteger;
|
||||
|
||||
/**
|
||||
* Parse a string into a bigInt.
|
||||
* Default base is 10.
|
||||
* Default alphabet is "0123456789abcdefghijklmnopqrstuvwxyz".
|
||||
* caseSensitive defaults to false.
|
||||
*/
|
||||
(string: string, base?: BigNumber, alphabet?: string, caseSensitive?: boolean): BigInteger;
|
||||
|
||||
/**
|
||||
* no-op.
|
||||
*/
|
||||
(bigInt: BigInteger): BigInteger;
|
||||
|
||||
/**
|
||||
* Constructs a bigInt from an array of digits in specified base.
|
||||
* The optional isNegative flag will make the number negative.
|
||||
*/
|
||||
fromArray: (digits: BigNumber[], base?: BigNumber, isNegative?: boolean) => BigInteger;
|
||||
|
||||
/**
|
||||
* Finds the greatest common denominator of a and b.
|
||||
*/
|
||||
gcd: (a: BigNumber, b: BigNumber) => BigInteger;
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if x is a BigInteger, false otherwise.
|
||||
*/
|
||||
isInstance: (x: any) => x is BigInteger;
|
||||
|
||||
/**
|
||||
* Finds the least common multiple of a and b.
|
||||
*/
|
||||
lcm: (a: BigNumber, b: BigNumber) => BigInteger;
|
||||
|
||||
/**
|
||||
* Returns the largest of a and b.
|
||||
*/
|
||||
max: (a: BigNumber, b: BigNumber) => BigInteger;
|
||||
|
||||
/**
|
||||
* Returns the smallest of a and b.
|
||||
*/
|
||||
min: (a: BigNumber, b: BigNumber) => BigInteger;
|
||||
|
||||
/**
|
||||
* Equivalent to bigInt(-1).
|
||||
*/
|
||||
minusOne: BigInteger;
|
||||
|
||||
/**
|
||||
* Equivalent to bigInt(1).
|
||||
*/
|
||||
one: BigInteger;
|
||||
|
||||
/**
|
||||
* Returns a random number between min and max.
|
||||
*/
|
||||
randBetween: (min: BigNumber, max: BigNumber, rng?: () => number) => BigInteger;
|
||||
|
||||
/**
|
||||
* Equivalent to bigInt(0).
|
||||
*/
|
||||
zero: BigInteger;
|
||||
}
|
||||
|
||||
interface BigInteger {
|
||||
/**
|
||||
* Returns the absolute value of a bigInt.
|
||||
*/
|
||||
abs(): BigInteger;
|
||||
|
||||
/**
|
||||
* Performs addition.
|
||||
*/
|
||||
add(number: BigNumber): BigInteger;
|
||||
|
||||
/**
|
||||
* Performs the bitwise AND operation.
|
||||
*/
|
||||
and(number: BigNumber): BigInteger;
|
||||
|
||||
/**
|
||||
* Returns the number of digits required to represent a bigInt in binary.
|
||||
*/
|
||||
bitLength(): BigInteger;
|
||||
|
||||
/**
|
||||
* Performs 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.
|
||||
*/
|
||||
compare(number: BigNumber): number;
|
||||
|
||||
/**
|
||||
* Performs a comparison between the absolute value of two numbers.
|
||||
*/
|
||||
compareAbs(number: BigNumber): number;
|
||||
|
||||
/**
|
||||
* Alias for the compare method.
|
||||
*/
|
||||
compareTo(number: BigNumber): number;
|
||||
|
||||
/**
|
||||
* Performs integer division, disregarding the remainder.
|
||||
*/
|
||||
divide(number: BigNumber): BigInteger;
|
||||
|
||||
/**
|
||||
* Performs division and returns an object with two properties: quotient and remainder.
|
||||
* The sign of the remainder will match the sign of the dividend.
|
||||
*/
|
||||
divmod(number: BigNumber): { quotient: BigInteger, remainder: BigInteger };
|
||||
|
||||
/**
|
||||
* Alias for the equals method.
|
||||
*/
|
||||
eq(number: BigNumber): boolean;
|
||||
|
||||
/**
|
||||
* Checks if two numbers are equal.
|
||||
*/
|
||||
equals(number: BigNumber): boolean;
|
||||
|
||||
/**
|
||||
* Alias for the greaterOrEquals method.
|
||||
*/
|
||||
geq(number: BigNumber): boolean;
|
||||
|
||||
/**
|
||||
* Checks if the first number is greater than the second.
|
||||
*/
|
||||
greater(number: BigNumber): boolean;
|
||||
|
||||
/**
|
||||
* Checks if the first number is greater than or equal to the second.
|
||||
*/
|
||||
greaterOrEquals(number: BigNumber): boolean;
|
||||
|
||||
/**
|
||||
* Alias for the greater method.
|
||||
*/
|
||||
gt(number: BigNumber): boolean;
|
||||
|
||||
/**
|
||||
* Returns true if the first number is divisible by the second number, false otherwise.
|
||||
*/
|
||||
isDivisibleBy(number: BigNumber): boolean;
|
||||
|
||||
/**
|
||||
* Returns true if the number is even, false otherwise.
|
||||
*/
|
||||
isEven(): boolean;
|
||||
|
||||
/**
|
||||
* Returns true if the number is negative, false otherwise.
|
||||
* Returns false for 0 and true for -0.
|
||||
*/
|
||||
isNegative(): boolean;
|
||||
|
||||
/**
|
||||
* Returns true if the number is odd, false otherwise.
|
||||
*/
|
||||
isOdd(): boolean;
|
||||
|
||||
/**
|
||||
* Return true if the number is positive, false otherwise.
|
||||
* Returns true for 0 and false for -0.
|
||||
*/
|
||||
isPositive(): boolean;
|
||||
|
||||
/**
|
||||
* Returns true if the number is prime, false otherwise.
|
||||
*/
|
||||
isPrime(strict?: boolean): boolean;
|
||||
|
||||
/**
|
||||
* Returns true if the number is very likely to be prime, false otherwise.
|
||||
*/
|
||||
isProbablePrime(iterations?: number, rng?: () => number): boolean;
|
||||
|
||||
/**
|
||||
* Returns true if the number is 1 or -1, false otherwise.
|
||||
*/
|
||||
isUnit(): boolean;
|
||||
|
||||
/**
|
||||
* Return true if the number is 0 or -0, false otherwise.
|
||||
*/
|
||||
isZero(): boolean;
|
||||
|
||||
/**
|
||||
* Alias for the lesserOrEquals method.
|
||||
*/
|
||||
leq(number: BigNumber): boolean;
|
||||
|
||||
/**
|
||||
* Checks if the first number is lesser than the second.
|
||||
*/
|
||||
lesser(number: BigNumber): boolean;
|
||||
|
||||
/**
|
||||
* Checks if the first number is less than or equal to the second.
|
||||
*/
|
||||
lesserOrEquals(number: BigNumber): boolean;
|
||||
|
||||
/**
|
||||
* Alias for the lesser method.
|
||||
*/
|
||||
lt(number: BigNumber): boolean;
|
||||
|
||||
/**
|
||||
* Alias for the subtract method.
|
||||
*/
|
||||
minus(number: BigNumber): BigInteger;
|
||||
|
||||
/**
|
||||
* Performs division and returns the remainder, disregarding the quotient.
|
||||
* The sign of the remainder will match the sign of the dividend.
|
||||
*/
|
||||
mod(number: BigNumber): BigInteger;
|
||||
|
||||
/**
|
||||
* Finds the multiplicative inverse of the number modulo mod.
|
||||
*/
|
||||
modInv(number: BigNumber): BigInteger;
|
||||
|
||||
/**
|
||||
* Takes the number to the power exp modulo mod.
|
||||
*/
|
||||
modPow(exp: BigNumber, mod: BigNumber): BigInteger;
|
||||
|
||||
/**
|
||||
* Performs multiplication.
|
||||
*/
|
||||
multiply(number: BigNumber): BigInteger;
|
||||
|
||||
/**
|
||||
* Reverses the sign of the number.
|
||||
*/
|
||||
negate(): BigInteger;
|
||||
|
||||
/**
|
||||
* Alias for the notEquals method.
|
||||
*/
|
||||
neq(number: BigNumber): boolean;
|
||||
|
||||
/**
|
||||
* Adds one to the number.
|
||||
*/
|
||||
next(): BigInteger;
|
||||
|
||||
/**
|
||||
* Performs the bitwise NOT operation.
|
||||
*/
|
||||
not(): BigInteger;
|
||||
|
||||
/**
|
||||
* Checks if two numbers are not equal.
|
||||
*/
|
||||
notEquals(number: BigNumber): boolean;
|
||||
|
||||
/**
|
||||
* Performs the bitwise OR operation.
|
||||
*/
|
||||
or(number: BigNumber): BigInteger;
|
||||
|
||||
/**
|
||||
* Alias for the divide method.
|
||||
*/
|
||||
over(number: BigNumber): BigInteger;
|
||||
|
||||
/**
|
||||
* Alias for the add method.
|
||||
*/
|
||||
plus(number: BigNumber): BigInteger;
|
||||
|
||||
/**
|
||||
* Performs exponentiation. If the exponent is less than 0, pow returns 0.
|
||||
* bigInt.zero.pow(0) returns 1.
|
||||
*/
|
||||
pow(number: BigNumber): BigInteger;
|
||||
|
||||
/**
|
||||
* Subtracts one from the number.
|
||||
*/
|
||||
prev(): BigInteger;
|
||||
|
||||
/**
|
||||
* Alias for the mod method.
|
||||
*/
|
||||
remainder(number: BigNumber): BigInteger;
|
||||
|
||||
/**
|
||||
* Shifts the number left by n places in its binary representation.
|
||||
* If a negative number is provided, it will shift right.
|
||||
*
|
||||
* Throws an error if number is outside of the range [-9007199254740992, 9007199254740992].
|
||||
*/
|
||||
shiftLeft(number: BigNumber): BigInteger;
|
||||
|
||||
/**
|
||||
* Shifts the number right by n places in its binary representation.
|
||||
* If a negative number is provided, it will shift left.
|
||||
*
|
||||
* Throws an error if number is outside of the range [-9007199254740992, 9007199254740992].
|
||||
*/
|
||||
shiftRight(number: BigNumber): BigInteger;
|
||||
|
||||
/**
|
||||
* Squares the number.
|
||||
*/
|
||||
square(): BigInteger;
|
||||
|
||||
/**
|
||||
* Performs subtraction.
|
||||
*/
|
||||
subtract(number: BigNumber): BigInteger;
|
||||
|
||||
/**
|
||||
* Alias for the multiply method.
|
||||
*/
|
||||
times(number: BigNumber): BigInteger;
|
||||
|
||||
/**
|
||||
*
|
||||
* Converts a bigInt to an object representing it as an array of integers module the given radix.
|
||||
*/
|
||||
toArray(radix: number): BaseArray;
|
||||
|
||||
/**
|
||||
* Converts a bigInt into a native Javascript number. Loses precision for numbers outside the range.
|
||||
*/
|
||||
toJSNumber(): number;
|
||||
|
||||
/**
|
||||
* Converts a bigInt to a string.
|
||||
*/
|
||||
toString(radix?: number, alphabet?: string): string;
|
||||
|
||||
/**
|
||||
* Converts a bigInt to a string. This method is called behind the scenes in JSON.stringify.
|
||||
*/
|
||||
toJSON(): string;
|
||||
|
||||
/**
|
||||
* Converts a bigInt to a native Javascript number. This override allows you to use native
|
||||
* arithmetic operators without explicit conversion.
|
||||
*/
|
||||
valueOf(): number;
|
||||
|
||||
/**
|
||||
* Performs the bitwise XOR operation.
|
||||
*/
|
||||
xor(number: BigNumber): BigInteger;
|
||||
}
|
||||
|
||||
// Array constant accessors
|
||||
interface BigIntegerStatic {
|
||||
'-999': BigInteger;
|
||||
'-998': BigInteger;
|
||||
'-997': BigInteger;
|
||||
'-996': BigInteger;
|
||||
'-995': BigInteger;
|
||||
'-994': BigInteger;
|
||||
'-993': BigInteger;
|
||||
'-992': BigInteger;
|
||||
'-991': BigInteger;
|
||||
'-990': BigInteger;
|
||||
'-989': BigInteger;
|
||||
'-988': BigInteger;
|
||||
'-987': BigInteger;
|
||||
'-986': BigInteger;
|
||||
'-985': BigInteger;
|
||||
'-984': BigInteger;
|
||||
'-983': BigInteger;
|
||||
'-982': BigInteger;
|
||||
'-981': BigInteger;
|
||||
'-980': BigInteger;
|
||||
'-979': BigInteger;
|
||||
'-978': BigInteger;
|
||||
'-977': BigInteger;
|
||||
'-976': BigInteger;
|
||||
'-975': BigInteger;
|
||||
'-974': BigInteger;
|
||||
'-973': BigInteger;
|
||||
'-972': BigInteger;
|
||||
'-971': BigInteger;
|
||||
'-970': BigInteger;
|
||||
'-969': BigInteger;
|
||||
'-968': BigInteger;
|
||||
'-967': BigInteger;
|
||||
'-966': BigInteger;
|
||||
'-965': BigInteger;
|
||||
'-964': BigInteger;
|
||||
'-963': BigInteger;
|
||||
'-962': BigInteger;
|
||||
'-961': BigInteger;
|
||||
'-960': BigInteger;
|
||||
'-959': BigInteger;
|
||||
'-958': BigInteger;
|
||||
'-957': BigInteger;
|
||||
'-956': BigInteger;
|
||||
'-955': BigInteger;
|
||||
'-954': BigInteger;
|
||||
'-953': BigInteger;
|
||||
'-952': BigInteger;
|
||||
'-951': BigInteger;
|
||||
'-950': BigInteger;
|
||||
'-949': BigInteger;
|
||||
'-948': BigInteger;
|
||||
'-947': BigInteger;
|
||||
'-946': BigInteger;
|
||||
'-945': BigInteger;
|
||||
'-944': BigInteger;
|
||||
'-943': BigInteger;
|
||||
'-942': BigInteger;
|
||||
'-941': BigInteger;
|
||||
'-940': BigInteger;
|
||||
'-939': BigInteger;
|
||||
'-938': BigInteger;
|
||||
'-937': BigInteger;
|
||||
'-936': BigInteger;
|
||||
'-935': BigInteger;
|
||||
'-934': BigInteger;
|
||||
'-933': BigInteger;
|
||||
'-932': BigInteger;
|
||||
'-931': BigInteger;
|
||||
'-930': BigInteger;
|
||||
'-929': BigInteger;
|
||||
'-928': BigInteger;
|
||||
'-927': BigInteger;
|
||||
'-926': BigInteger;
|
||||
'-925': BigInteger;
|
||||
'-924': BigInteger;
|
||||
'-923': BigInteger;
|
||||
'-922': BigInteger;
|
||||
'-921': BigInteger;
|
||||
'-920': BigInteger;
|
||||
'-919': BigInteger;
|
||||
'-918': BigInteger;
|
||||
'-917': BigInteger;
|
||||
'-916': BigInteger;
|
||||
'-915': BigInteger;
|
||||
'-914': BigInteger;
|
||||
'-913': BigInteger;
|
||||
'-912': BigInteger;
|
||||
'-911': BigInteger;
|
||||
'-910': BigInteger;
|
||||
'-909': BigInteger;
|
||||
'-908': BigInteger;
|
||||
'-907': BigInteger;
|
||||
'-906': BigInteger;
|
||||
'-905': BigInteger;
|
||||
'-904': BigInteger;
|
||||
'-903': BigInteger;
|
||||
'-902': BigInteger;
|
||||
'-901': BigInteger;
|
||||
'-900': BigInteger;
|
||||
'-899': BigInteger;
|
||||
'-898': BigInteger;
|
||||
'-897': BigInteger;
|
||||
'-896': BigInteger;
|
||||
'-895': BigInteger;
|
||||
'-894': BigInteger;
|
||||
'-893': BigInteger;
|
||||
'-892': BigInteger;
|
||||
'-891': BigInteger;
|
||||
'-890': BigInteger;
|
||||
'-889': BigInteger;
|
||||
'-888': BigInteger;
|
||||
'-887': BigInteger;
|
||||
'-886': BigInteger;
|
||||
'-885': BigInteger;
|
||||
'-884': BigInteger;
|
||||
'-883': BigInteger;
|
||||
'-882': BigInteger;
|
||||
'-881': BigInteger;
|
||||
'-880': BigInteger;
|
||||
'-879': BigInteger;
|
||||
'-878': BigInteger;
|
||||
'-877': BigInteger;
|
||||
'-876': BigInteger;
|
||||
'-875': BigInteger;
|
||||
'-874': BigInteger;
|
||||
'-873': BigInteger;
|
||||
'-872': BigInteger;
|
||||
'-871': BigInteger;
|
||||
'-870': BigInteger;
|
||||
'-869': BigInteger;
|
||||
'-868': BigInteger;
|
||||
'-867': BigInteger;
|
||||
'-866': BigInteger;
|
||||
'-865': BigInteger;
|
||||
'-864': BigInteger;
|
||||
'-863': BigInteger;
|
||||
'-862': BigInteger;
|
||||
'-861': BigInteger;
|
||||
'-860': BigInteger;
|
||||
'-859': BigInteger;
|
||||
'-858': BigInteger;
|
||||
'-857': BigInteger;
|
||||
'-856': BigInteger;
|
||||
'-855': BigInteger;
|
||||
'-854': BigInteger;
|
||||
'-853': BigInteger;
|
||||
'-852': BigInteger;
|
||||
'-851': BigInteger;
|
||||
'-850': BigInteger;
|
||||
'-849': BigInteger;
|
||||
'-848': BigInteger;
|
||||
'-847': BigInteger;
|
||||
'-846': BigInteger;
|
||||
'-845': BigInteger;
|
||||
'-844': BigInteger;
|
||||
'-843': BigInteger;
|
||||
'-842': BigInteger;
|
||||
'-841': BigInteger;
|
||||
'-840': BigInteger;
|
||||
'-839': BigInteger;
|
||||
'-838': BigInteger;
|
||||
'-837': BigInteger;
|
||||
'-836': BigInteger;
|
||||
'-835': BigInteger;
|
||||
'-834': BigInteger;
|
||||
'-833': BigInteger;
|
||||
'-832': BigInteger;
|
||||
'-831': BigInteger;
|
||||
'-830': BigInteger;
|
||||
'-829': BigInteger;
|
||||
'-828': BigInteger;
|
||||
'-827': BigInteger;
|
||||
'-826': BigInteger;
|
||||
'-825': BigInteger;
|
||||
'-824': BigInteger;
|
||||
'-823': BigInteger;
|
||||
'-822': BigInteger;
|
||||
'-821': BigInteger;
|
||||
'-820': BigInteger;
|
||||
'-819': BigInteger;
|
||||
'-818': BigInteger;
|
||||
'-817': BigInteger;
|
||||
'-816': BigInteger;
|
||||
'-815': BigInteger;
|
||||
'-814': BigInteger;
|
||||
'-813': BigInteger;
|
||||
'-812': BigInteger;
|
||||
'-811': BigInteger;
|
||||
'-810': BigInteger;
|
||||
'-809': BigInteger;
|
||||
'-808': BigInteger;
|
||||
'-807': BigInteger;
|
||||
'-806': BigInteger;
|
||||
'-805': BigInteger;
|
||||
'-804': BigInteger;
|
||||
'-803': BigInteger;
|
||||
'-802': BigInteger;
|
||||
'-801': BigInteger;
|
||||
'-800': BigInteger;
|
||||
'-799': BigInteger;
|
||||
'-798': BigInteger;
|
||||
'-797': BigInteger;
|
||||
'-796': BigInteger;
|
||||
'-795': BigInteger;
|
||||
'-794': BigInteger;
|
||||
'-793': BigInteger;
|
||||
'-792': BigInteger;
|
||||
'-791': BigInteger;
|
||||
'-790': BigInteger;
|
||||
'-789': BigInteger;
|
||||
'-788': BigInteger;
|
||||
'-787': BigInteger;
|
||||
'-786': BigInteger;
|
||||
'-785': BigInteger;
|
||||
'-784': BigInteger;
|
||||
'-783': BigInteger;
|
||||
'-782': BigInteger;
|
||||
'-781': BigInteger;
|
||||
'-780': BigInteger;
|
||||
'-779': BigInteger;
|
||||
'-778': BigInteger;
|
||||
'-777': BigInteger;
|
||||
'-776': BigInteger;
|
||||
'-775': BigInteger;
|
||||
'-774': BigInteger;
|
||||
'-773': BigInteger;
|
||||
'-772': BigInteger;
|
||||
'-771': BigInteger;
|
||||
'-770': BigInteger;
|
||||
'-769': BigInteger;
|
||||
'-768': BigInteger;
|
||||
'-767': BigInteger;
|
||||
'-766': BigInteger;
|
||||
'-765': BigInteger;
|
||||
'-764': BigInteger;
|
||||
'-763': BigInteger;
|
||||
'-762': BigInteger;
|
||||
'-761': BigInteger;
|
||||
'-760': BigInteger;
|
||||
'-759': BigInteger;
|
||||
'-758': BigInteger;
|
||||
'-757': BigInteger;
|
||||
'-756': BigInteger;
|
||||
'-755': BigInteger;
|
||||
'-754': BigInteger;
|
||||
'-753': BigInteger;
|
||||
'-752': BigInteger;
|
||||
'-751': BigInteger;
|
||||
'-750': BigInteger;
|
||||
'-749': BigInteger;
|
||||
'-748': BigInteger;
|
||||
'-747': BigInteger;
|
||||
'-746': BigInteger;
|
||||
'-745': BigInteger;
|
||||
'-744': BigInteger;
|
||||
'-743': BigInteger;
|
||||
'-742': BigInteger;
|
||||
'-741': BigInteger;
|
||||
'-740': BigInteger;
|
||||
'-739': BigInteger;
|
||||
'-738': BigInteger;
|
||||
'-737': BigInteger;
|
||||
'-736': BigInteger;
|
||||
'-735': BigInteger;
|
||||
'-734': BigInteger;
|
||||
'-733': BigInteger;
|
||||
'-732': BigInteger;
|
||||
'-731': BigInteger;
|
||||
'-730': BigInteger;
|
||||
'-729': BigInteger;
|
||||
'-728': BigInteger;
|
||||
'-727': BigInteger;
|
||||
'-726': BigInteger;
|
||||
'-725': BigInteger;
|
||||
'-724': BigInteger;
|
||||
'-723': BigInteger;
|
||||
'-722': BigInteger;
|
||||
'-721': BigInteger;
|
||||
'-720': BigInteger;
|
||||
'-719': BigInteger;
|
||||
'-718': BigInteger;
|
||||
'-717': BigInteger;
|
||||
'-716': BigInteger;
|
||||
'-715': BigInteger;
|
||||
'-714': BigInteger;
|
||||
'-713': BigInteger;
|
||||
'-712': BigInteger;
|
||||
'-711': BigInteger;
|
||||
'-710': BigInteger;
|
||||
'-709': BigInteger;
|
||||
'-708': BigInteger;
|
||||
'-707': BigInteger;
|
||||
'-706': BigInteger;
|
||||
'-705': BigInteger;
|
||||
'-704': BigInteger;
|
||||
'-703': BigInteger;
|
||||
'-702': BigInteger;
|
||||
'-701': BigInteger;
|
||||
'-700': BigInteger;
|
||||
'-699': BigInteger;
|
||||
'-698': BigInteger;
|
||||
'-697': BigInteger;
|
||||
'-696': BigInteger;
|
||||
'-695': BigInteger;
|
||||
'-694': BigInteger;
|
||||
'-693': BigInteger;
|
||||
'-692': BigInteger;
|
||||
'-691': BigInteger;
|
||||
'-690': BigInteger;
|
||||
'-689': BigInteger;
|
||||
'-688': BigInteger;
|
||||
'-687': BigInteger;
|
||||
'-686': BigInteger;
|
||||
'-685': BigInteger;
|
||||
'-684': BigInteger;
|
||||
'-683': BigInteger;
|
||||
'-682': BigInteger;
|
||||
'-681': BigInteger;
|
||||
'-680': BigInteger;
|
||||
'-679': BigInteger;
|
||||
'-678': BigInteger;
|
||||
'-677': BigInteger;
|
||||
'-676': BigInteger;
|
||||
'-675': BigInteger;
|
||||
'-674': BigInteger;
|
||||
'-673': BigInteger;
|
||||
'-672': BigInteger;
|
||||
'-671': BigInteger;
|
||||
'-670': BigInteger;
|
||||
'-669': BigInteger;
|
||||
'-668': BigInteger;
|
||||
'-667': BigInteger;
|
||||
'-666': BigInteger;
|
||||
'-665': BigInteger;
|
||||
'-664': BigInteger;
|
||||
'-663': BigInteger;
|
||||
'-662': BigInteger;
|
||||
'-661': BigInteger;
|
||||
'-660': BigInteger;
|
||||
'-659': BigInteger;
|
||||
'-658': BigInteger;
|
||||
'-657': BigInteger;
|
||||
'-656': BigInteger;
|
||||
'-655': BigInteger;
|
||||
'-654': BigInteger;
|
||||
'-653': BigInteger;
|
||||
'-652': BigInteger;
|
||||
'-651': BigInteger;
|
||||
'-650': BigInteger;
|
||||
'-649': BigInteger;
|
||||
'-648': BigInteger;
|
||||
'-647': BigInteger;
|
||||
'-646': BigInteger;
|
||||
'-645': BigInteger;
|
||||
'-644': BigInteger;
|
||||
'-643': BigInteger;
|
||||
'-642': BigInteger;
|
||||
'-641': BigInteger;
|
||||
'-640': BigInteger;
|
||||
'-639': BigInteger;
|
||||
'-638': BigInteger;
|
||||
'-637': BigInteger;
|
||||
'-636': BigInteger;
|
||||
'-635': BigInteger;
|
||||
'-634': BigInteger;
|
||||
'-633': BigInteger;
|
||||
'-632': BigInteger;
|
||||
'-631': BigInteger;
|
||||
'-630': BigInteger;
|
||||
'-629': BigInteger;
|
||||
'-628': BigInteger;
|
||||
'-627': BigInteger;
|
||||
'-626': BigInteger;
|
||||
'-625': BigInteger;
|
||||
'-624': BigInteger;
|
||||
'-623': BigInteger;
|
||||
'-622': BigInteger;
|
||||
'-621': BigInteger;
|
||||
'-620': BigInteger;
|
||||
'-619': BigInteger;
|
||||
'-618': BigInteger;
|
||||
'-617': BigInteger;
|
||||
'-616': BigInteger;
|
||||
'-615': BigInteger;
|
||||
'-614': BigInteger;
|
||||
'-613': BigInteger;
|
||||
'-612': BigInteger;
|
||||
'-611': BigInteger;
|
||||
'-610': BigInteger;
|
||||
'-609': BigInteger;
|
||||
'-608': BigInteger;
|
||||
'-607': BigInteger;
|
||||
'-606': BigInteger;
|
||||
'-605': BigInteger;
|
||||
'-604': BigInteger;
|
||||
'-603': BigInteger;
|
||||
'-602': BigInteger;
|
||||
'-601': BigInteger;
|
||||
'-600': BigInteger;
|
||||
'-599': BigInteger;
|
||||
'-598': BigInteger;
|
||||
'-597': BigInteger;
|
||||
'-596': BigInteger;
|
||||
'-595': BigInteger;
|
||||
'-594': BigInteger;
|
||||
'-593': BigInteger;
|
||||
'-592': BigInteger;
|
||||
'-591': BigInteger;
|
||||
'-590': BigInteger;
|
||||
'-589': BigInteger;
|
||||
'-588': BigInteger;
|
||||
'-587': BigInteger;
|
||||
'-586': BigInteger;
|
||||
'-585': BigInteger;
|
||||
'-584': BigInteger;
|
||||
'-583': BigInteger;
|
||||
'-582': BigInteger;
|
||||
'-581': BigInteger;
|
||||
'-580': BigInteger;
|
||||
'-579': BigInteger;
|
||||
'-578': BigInteger;
|
||||
'-577': BigInteger;
|
||||
'-576': BigInteger;
|
||||
'-575': BigInteger;
|
||||
'-574': BigInteger;
|
||||
'-573': BigInteger;
|
||||
'-572': BigInteger;
|
||||
'-571': BigInteger;
|
||||
'-570': BigInteger;
|
||||
'-569': BigInteger;
|
||||
'-568': BigInteger;
|
||||
'-567': BigInteger;
|
||||
'-566': BigInteger;
|
||||
'-565': BigInteger;
|
||||
'-564': BigInteger;
|
||||
'-563': BigInteger;
|
||||
'-562': BigInteger;
|
||||
'-561': BigInteger;
|
||||
'-560': BigInteger;
|
||||
'-559': BigInteger;
|
||||
'-558': BigInteger;
|
||||
'-557': BigInteger;
|
||||
'-556': BigInteger;
|
||||
'-555': BigInteger;
|
||||
'-554': BigInteger;
|
||||
'-553': BigInteger;
|
||||
'-552': BigInteger;
|
||||
'-551': BigInteger;
|
||||
'-550': BigInteger;
|
||||
'-549': BigInteger;
|
||||
'-548': BigInteger;
|
||||
'-547': BigInteger;
|
||||
'-546': BigInteger;
|
||||
'-545': BigInteger;
|
||||
'-544': BigInteger;
|
||||
'-543': BigInteger;
|
||||
'-542': BigInteger;
|
||||
'-541': BigInteger;
|
||||
'-540': BigInteger;
|
||||
'-539': BigInteger;
|
||||
'-538': BigInteger;
|
||||
'-537': BigInteger;
|
||||
'-536': BigInteger;
|
||||
'-535': BigInteger;
|
||||
'-534': BigInteger;
|
||||
'-533': BigInteger;
|
||||
'-532': BigInteger;
|
||||
'-531': BigInteger;
|
||||
'-530': BigInteger;
|
||||
'-529': BigInteger;
|
||||
'-528': BigInteger;
|
||||
'-527': BigInteger;
|
||||
'-526': BigInteger;
|
||||
'-525': BigInteger;
|
||||
'-524': BigInteger;
|
||||
'-523': BigInteger;
|
||||
'-522': BigInteger;
|
||||
'-521': BigInteger;
|
||||
'-520': BigInteger;
|
||||
'-519': BigInteger;
|
||||
'-518': BigInteger;
|
||||
'-517': BigInteger;
|
||||
'-516': BigInteger;
|
||||
'-515': BigInteger;
|
||||
'-514': BigInteger;
|
||||
'-513': BigInteger;
|
||||
'-512': BigInteger;
|
||||
'-511': BigInteger;
|
||||
'-510': BigInteger;
|
||||
'-509': BigInteger;
|
||||
'-508': BigInteger;
|
||||
'-507': BigInteger;
|
||||
'-506': BigInteger;
|
||||
'-505': BigInteger;
|
||||
'-504': BigInteger;
|
||||
'-503': BigInteger;
|
||||
'-502': BigInteger;
|
||||
'-501': BigInteger;
|
||||
'-500': BigInteger;
|
||||
'-499': BigInteger;
|
||||
'-498': BigInteger;
|
||||
'-497': BigInteger;
|
||||
'-496': BigInteger;
|
||||
'-495': BigInteger;
|
||||
'-494': BigInteger;
|
||||
'-493': BigInteger;
|
||||
'-492': BigInteger;
|
||||
'-491': BigInteger;
|
||||
'-490': BigInteger;
|
||||
'-489': BigInteger;
|
||||
'-488': BigInteger;
|
||||
'-487': BigInteger;
|
||||
'-486': BigInteger;
|
||||
'-485': BigInteger;
|
||||
'-484': BigInteger;
|
||||
'-483': BigInteger;
|
||||
'-482': BigInteger;
|
||||
'-481': BigInteger;
|
||||
'-480': BigInteger;
|
||||
'-479': BigInteger;
|
||||
'-478': BigInteger;
|
||||
'-477': BigInteger;
|
||||
'-476': BigInteger;
|
||||
'-475': BigInteger;
|
||||
'-474': BigInteger;
|
||||
'-473': BigInteger;
|
||||
'-472': BigInteger;
|
||||
'-471': BigInteger;
|
||||
'-470': BigInteger;
|
||||
'-469': BigInteger;
|
||||
'-468': BigInteger;
|
||||
'-467': BigInteger;
|
||||
'-466': BigInteger;
|
||||
'-465': BigInteger;
|
||||
'-464': BigInteger;
|
||||
'-463': BigInteger;
|
||||
'-462': BigInteger;
|
||||
'-461': BigInteger;
|
||||
'-460': BigInteger;
|
||||
'-459': BigInteger;
|
||||
'-458': BigInteger;
|
||||
'-457': BigInteger;
|
||||
'-456': BigInteger;
|
||||
'-455': BigInteger;
|
||||
'-454': BigInteger;
|
||||
'-453': BigInteger;
|
||||
'-452': BigInteger;
|
||||
'-451': BigInteger;
|
||||
'-450': BigInteger;
|
||||
'-449': BigInteger;
|
||||
'-448': BigInteger;
|
||||
'-447': BigInteger;
|
||||
'-446': BigInteger;
|
||||
'-445': BigInteger;
|
||||
'-444': BigInteger;
|
||||
'-443': BigInteger;
|
||||
'-442': BigInteger;
|
||||
'-441': BigInteger;
|
||||
'-440': BigInteger;
|
||||
'-439': BigInteger;
|
||||
'-438': BigInteger;
|
||||
'-437': BigInteger;
|
||||
'-436': BigInteger;
|
||||
'-435': BigInteger;
|
||||
'-434': BigInteger;
|
||||
'-433': BigInteger;
|
||||
'-432': BigInteger;
|
||||
'-431': BigInteger;
|
||||
'-430': BigInteger;
|
||||
'-429': BigInteger;
|
||||
'-428': BigInteger;
|
||||
'-427': BigInteger;
|
||||
'-426': BigInteger;
|
||||
'-425': BigInteger;
|
||||
'-424': BigInteger;
|
||||
'-423': BigInteger;
|
||||
'-422': BigInteger;
|
||||
'-421': BigInteger;
|
||||
'-420': BigInteger;
|
||||
'-419': BigInteger;
|
||||
'-418': BigInteger;
|
||||
'-417': BigInteger;
|
||||
'-416': BigInteger;
|
||||
'-415': BigInteger;
|
||||
'-414': BigInteger;
|
||||
'-413': BigInteger;
|
||||
'-412': BigInteger;
|
||||
'-411': BigInteger;
|
||||
'-410': BigInteger;
|
||||
'-409': BigInteger;
|
||||
'-408': BigInteger;
|
||||
'-407': BigInteger;
|
||||
'-406': BigInteger;
|
||||
'-405': BigInteger;
|
||||
'-404': BigInteger;
|
||||
'-403': BigInteger;
|
||||
'-402': BigInteger;
|
||||
'-401': BigInteger;
|
||||
'-400': BigInteger;
|
||||
'-399': BigInteger;
|
||||
'-398': BigInteger;
|
||||
'-397': BigInteger;
|
||||
'-396': BigInteger;
|
||||
'-395': BigInteger;
|
||||
'-394': BigInteger;
|
||||
'-393': BigInteger;
|
||||
'-392': BigInteger;
|
||||
'-391': BigInteger;
|
||||
'-390': BigInteger;
|
||||
'-389': BigInteger;
|
||||
'-388': BigInteger;
|
||||
'-387': BigInteger;
|
||||
'-386': BigInteger;
|
||||
'-385': BigInteger;
|
||||
'-384': BigInteger;
|
||||
'-383': BigInteger;
|
||||
'-382': BigInteger;
|
||||
'-381': BigInteger;
|
||||
'-380': BigInteger;
|
||||
'-379': BigInteger;
|
||||
'-378': BigInteger;
|
||||
'-377': BigInteger;
|
||||
'-376': BigInteger;
|
||||
'-375': BigInteger;
|
||||
'-374': BigInteger;
|
||||
'-373': BigInteger;
|
||||
'-372': BigInteger;
|
||||
'-371': BigInteger;
|
||||
'-370': BigInteger;
|
||||
'-369': BigInteger;
|
||||
'-368': BigInteger;
|
||||
'-367': BigInteger;
|
||||
'-366': BigInteger;
|
||||
'-365': BigInteger;
|
||||
'-364': BigInteger;
|
||||
'-363': BigInteger;
|
||||
'-362': BigInteger;
|
||||
'-361': BigInteger;
|
||||
'-360': BigInteger;
|
||||
'-359': BigInteger;
|
||||
'-358': BigInteger;
|
||||
'-357': BigInteger;
|
||||
'-356': BigInteger;
|
||||
'-355': BigInteger;
|
||||
'-354': BigInteger;
|
||||
'-353': BigInteger;
|
||||
'-352': BigInteger;
|
||||
'-351': BigInteger;
|
||||
'-350': BigInteger;
|
||||
'-349': BigInteger;
|
||||
'-348': BigInteger;
|
||||
'-347': BigInteger;
|
||||
'-346': BigInteger;
|
||||
'-345': BigInteger;
|
||||
'-344': BigInteger;
|
||||
'-343': BigInteger;
|
||||
'-342': BigInteger;
|
||||
'-341': BigInteger;
|
||||
'-340': BigInteger;
|
||||
'-339': BigInteger;
|
||||
'-338': BigInteger;
|
||||
'-337': BigInteger;
|
||||
'-336': BigInteger;
|
||||
'-335': BigInteger;
|
||||
'-334': BigInteger;
|
||||
'-333': BigInteger;
|
||||
'-332': BigInteger;
|
||||
'-331': BigInteger;
|
||||
'-330': BigInteger;
|
||||
'-329': BigInteger;
|
||||
'-328': BigInteger;
|
||||
'-327': BigInteger;
|
||||
'-326': BigInteger;
|
||||
'-325': BigInteger;
|
||||
'-324': BigInteger;
|
||||
'-323': BigInteger;
|
||||
'-322': BigInteger;
|
||||
'-321': BigInteger;
|
||||
'-320': BigInteger;
|
||||
'-319': BigInteger;
|
||||
'-318': BigInteger;
|
||||
'-317': BigInteger;
|
||||
'-316': BigInteger;
|
||||
'-315': BigInteger;
|
||||
'-314': BigInteger;
|
||||
'-313': BigInteger;
|
||||
'-312': BigInteger;
|
||||
'-311': BigInteger;
|
||||
'-310': BigInteger;
|
||||
'-309': BigInteger;
|
||||
'-308': BigInteger;
|
||||
'-307': BigInteger;
|
||||
'-306': BigInteger;
|
||||
'-305': BigInteger;
|
||||
'-304': BigInteger;
|
||||
'-303': BigInteger;
|
||||
'-302': BigInteger;
|
||||
'-301': BigInteger;
|
||||
'-300': BigInteger;
|
||||
'-299': BigInteger;
|
||||
'-298': BigInteger;
|
||||
'-297': BigInteger;
|
||||
'-296': BigInteger;
|
||||
'-295': BigInteger;
|
||||
'-294': BigInteger;
|
||||
'-293': BigInteger;
|
||||
'-292': BigInteger;
|
||||
'-291': BigInteger;
|
||||
'-290': BigInteger;
|
||||
'-289': BigInteger;
|
||||
'-288': BigInteger;
|
||||
'-287': BigInteger;
|
||||
'-286': BigInteger;
|
||||
'-285': BigInteger;
|
||||
'-284': BigInteger;
|
||||
'-283': BigInteger;
|
||||
'-282': BigInteger;
|
||||
'-281': BigInteger;
|
||||
'-280': BigInteger;
|
||||
'-279': BigInteger;
|
||||
'-278': BigInteger;
|
||||
'-277': BigInteger;
|
||||
'-276': BigInteger;
|
||||
'-275': BigInteger;
|
||||
'-274': BigInteger;
|
||||
'-273': BigInteger;
|
||||
'-272': BigInteger;
|
||||
'-271': BigInteger;
|
||||
'-270': BigInteger;
|
||||
'-269': BigInteger;
|
||||
'-268': BigInteger;
|
||||
'-267': BigInteger;
|
||||
'-266': BigInteger;
|
||||
'-265': BigInteger;
|
||||
'-264': BigInteger;
|
||||
'-263': BigInteger;
|
||||
'-262': BigInteger;
|
||||
'-261': BigInteger;
|
||||
'-260': BigInteger;
|
||||
'-259': BigInteger;
|
||||
'-258': BigInteger;
|
||||
'-257': BigInteger;
|
||||
'-256': BigInteger;
|
||||
'-255': BigInteger;
|
||||
'-254': BigInteger;
|
||||
'-253': BigInteger;
|
||||
'-252': BigInteger;
|
||||
'-251': BigInteger;
|
||||
'-250': BigInteger;
|
||||
'-249': BigInteger;
|
||||
'-248': BigInteger;
|
||||
'-247': BigInteger;
|
||||
'-246': BigInteger;
|
||||
'-245': BigInteger;
|
||||
'-244': BigInteger;
|
||||
'-243': BigInteger;
|
||||
'-242': BigInteger;
|
||||
'-241': BigInteger;
|
||||
'-240': BigInteger;
|
||||
'-239': BigInteger;
|
||||
'-238': BigInteger;
|
||||
'-237': BigInteger;
|
||||
'-236': BigInteger;
|
||||
'-235': BigInteger;
|
||||
'-234': BigInteger;
|
||||
'-233': BigInteger;
|
||||
'-232': BigInteger;
|
||||
'-231': BigInteger;
|
||||
'-230': BigInteger;
|
||||
'-229': BigInteger;
|
||||
'-228': BigInteger;
|
||||
'-227': BigInteger;
|
||||
'-226': BigInteger;
|
||||
'-225': BigInteger;
|
||||
'-224': BigInteger;
|
||||
'-223': BigInteger;
|
||||
'-222': BigInteger;
|
||||
'-221': BigInteger;
|
||||
'-220': BigInteger;
|
||||
'-219': BigInteger;
|
||||
'-218': BigInteger;
|
||||
'-217': BigInteger;
|
||||
'-216': BigInteger;
|
||||
'-215': BigInteger;
|
||||
'-214': BigInteger;
|
||||
'-213': BigInteger;
|
||||
'-212': BigInteger;
|
||||
'-211': BigInteger;
|
||||
'-210': BigInteger;
|
||||
'-209': BigInteger;
|
||||
'-208': BigInteger;
|
||||
'-207': BigInteger;
|
||||
'-206': BigInteger;
|
||||
'-205': BigInteger;
|
||||
'-204': BigInteger;
|
||||
'-203': BigInteger;
|
||||
'-202': BigInteger;
|
||||
'-201': BigInteger;
|
||||
'-200': BigInteger;
|
||||
'-199': BigInteger;
|
||||
'-198': BigInteger;
|
||||
'-197': BigInteger;
|
||||
'-196': BigInteger;
|
||||
'-195': BigInteger;
|
||||
'-194': BigInteger;
|
||||
'-193': BigInteger;
|
||||
'-192': BigInteger;
|
||||
'-191': BigInteger;
|
||||
'-190': BigInteger;
|
||||
'-189': BigInteger;
|
||||
'-188': BigInteger;
|
||||
'-187': BigInteger;
|
||||
'-186': BigInteger;
|
||||
'-185': BigInteger;
|
||||
'-184': BigInteger;
|
||||
'-183': BigInteger;
|
||||
'-182': BigInteger;
|
||||
'-181': BigInteger;
|
||||
'-180': BigInteger;
|
||||
'-179': BigInteger;
|
||||
'-178': BigInteger;
|
||||
'-177': BigInteger;
|
||||
'-176': BigInteger;
|
||||
'-175': BigInteger;
|
||||
'-174': BigInteger;
|
||||
'-173': BigInteger;
|
||||
'-172': BigInteger;
|
||||
'-171': BigInteger;
|
||||
'-170': BigInteger;
|
||||
'-169': BigInteger;
|
||||
'-168': BigInteger;
|
||||
'-167': BigInteger;
|
||||
'-166': BigInteger;
|
||||
'-165': BigInteger;
|
||||
'-164': BigInteger;
|
||||
'-163': BigInteger;
|
||||
'-162': BigInteger;
|
||||
'-161': BigInteger;
|
||||
'-160': BigInteger;
|
||||
'-159': BigInteger;
|
||||
'-158': BigInteger;
|
||||
'-157': BigInteger;
|
||||
'-156': BigInteger;
|
||||
'-155': BigInteger;
|
||||
'-154': BigInteger;
|
||||
'-153': BigInteger;
|
||||
'-152': BigInteger;
|
||||
'-151': BigInteger;
|
||||
'-150': BigInteger;
|
||||
'-149': BigInteger;
|
||||
'-148': BigInteger;
|
||||
'-147': BigInteger;
|
||||
'-146': BigInteger;
|
||||
'-145': BigInteger;
|
||||
'-144': BigInteger;
|
||||
'-143': BigInteger;
|
||||
'-142': BigInteger;
|
||||
'-141': BigInteger;
|
||||
'-140': BigInteger;
|
||||
'-139': BigInteger;
|
||||
'-138': BigInteger;
|
||||
'-137': BigInteger;
|
||||
'-136': BigInteger;
|
||||
'-135': BigInteger;
|
||||
'-134': BigInteger;
|
||||
'-133': BigInteger;
|
||||
'-132': BigInteger;
|
||||
'-131': BigInteger;
|
||||
'-130': BigInteger;
|
||||
'-129': BigInteger;
|
||||
'-128': BigInteger;
|
||||
'-127': BigInteger;
|
||||
'-126': BigInteger;
|
||||
'-125': BigInteger;
|
||||
'-124': BigInteger;
|
||||
'-123': BigInteger;
|
||||
'-122': BigInteger;
|
||||
'-121': BigInteger;
|
||||
'-120': BigInteger;
|
||||
'-119': BigInteger;
|
||||
'-118': BigInteger;
|
||||
'-117': BigInteger;
|
||||
'-116': BigInteger;
|
||||
'-115': BigInteger;
|
||||
'-114': BigInteger;
|
||||
'-113': BigInteger;
|
||||
'-112': BigInteger;
|
||||
'-111': BigInteger;
|
||||
'-110': BigInteger;
|
||||
'-109': BigInteger;
|
||||
'-108': BigInteger;
|
||||
'-107': BigInteger;
|
||||
'-106': BigInteger;
|
||||
'-105': BigInteger;
|
||||
'-104': BigInteger;
|
||||
'-103': BigInteger;
|
||||
'-102': BigInteger;
|
||||
'-101': BigInteger;
|
||||
'-100': BigInteger;
|
||||
'-99': BigInteger;
|
||||
'-98': BigInteger;
|
||||
'-97': BigInteger;
|
||||
'-96': BigInteger;
|
||||
'-95': BigInteger;
|
||||
'-94': BigInteger;
|
||||
'-93': BigInteger;
|
||||
'-92': BigInteger;
|
||||
'-91': BigInteger;
|
||||
'-90': BigInteger;
|
||||
'-89': BigInteger;
|
||||
'-88': BigInteger;
|
||||
'-87': BigInteger;
|
||||
'-86': BigInteger;
|
||||
'-85': BigInteger;
|
||||
'-84': BigInteger;
|
||||
'-83': BigInteger;
|
||||
'-82': BigInteger;
|
||||
'-81': BigInteger;
|
||||
'-80': BigInteger;
|
||||
'-79': BigInteger;
|
||||
'-78': BigInteger;
|
||||
'-77': BigInteger;
|
||||
'-76': BigInteger;
|
||||
'-75': BigInteger;
|
||||
'-74': BigInteger;
|
||||
'-73': BigInteger;
|
||||
'-72': BigInteger;
|
||||
'-71': BigInteger;
|
||||
'-70': BigInteger;
|
||||
'-69': BigInteger;
|
||||
'-68': BigInteger;
|
||||
'-67': BigInteger;
|
||||
'-66': BigInteger;
|
||||
'-65': BigInteger;
|
||||
'-64': BigInteger;
|
||||
'-63': BigInteger;
|
||||
'-62': BigInteger;
|
||||
'-61': BigInteger;
|
||||
'-60': BigInteger;
|
||||
'-59': BigInteger;
|
||||
'-58': BigInteger;
|
||||
'-57': BigInteger;
|
||||
'-56': BigInteger;
|
||||
'-55': BigInteger;
|
||||
'-54': BigInteger;
|
||||
'-53': BigInteger;
|
||||
'-52': BigInteger;
|
||||
'-51': BigInteger;
|
||||
'-50': BigInteger;
|
||||
'-49': BigInteger;
|
||||
'-48': BigInteger;
|
||||
'-47': BigInteger;
|
||||
'-46': BigInteger;
|
||||
'-45': BigInteger;
|
||||
'-44': BigInteger;
|
||||
'-43': BigInteger;
|
||||
'-42': BigInteger;
|
||||
'-41': BigInteger;
|
||||
'-40': BigInteger;
|
||||
'-39': BigInteger;
|
||||
'-38': BigInteger;
|
||||
'-37': BigInteger;
|
||||
'-36': BigInteger;
|
||||
'-35': BigInteger;
|
||||
'-34': BigInteger;
|
||||
'-33': BigInteger;
|
||||
'-32': BigInteger;
|
||||
'-31': BigInteger;
|
||||
'-30': BigInteger;
|
||||
'-29': BigInteger;
|
||||
'-28': BigInteger;
|
||||
'-27': BigInteger;
|
||||
'-26': BigInteger;
|
||||
'-25': BigInteger;
|
||||
'-24': BigInteger;
|
||||
'-23': BigInteger;
|
||||
'-22': BigInteger;
|
||||
'-21': BigInteger;
|
||||
'-20': BigInteger;
|
||||
'-19': BigInteger;
|
||||
'-18': BigInteger;
|
||||
'-17': BigInteger;
|
||||
'-16': BigInteger;
|
||||
'-15': BigInteger;
|
||||
'-14': BigInteger;
|
||||
'-13': BigInteger;
|
||||
'-12': BigInteger;
|
||||
'-11': BigInteger;
|
||||
'-10': BigInteger;
|
||||
'-9': BigInteger;
|
||||
'-8': BigInteger;
|
||||
'-7': BigInteger;
|
||||
'-6': BigInteger;
|
||||
'-5': BigInteger;
|
||||
'-4': BigInteger;
|
||||
'-3': BigInteger;
|
||||
'-2': BigInteger;
|
||||
'-1': BigInteger;
|
||||
'0': BigInteger;
|
||||
'1': BigInteger;
|
||||
'2': BigInteger;
|
||||
'3': BigInteger;
|
||||
'4': BigInteger;
|
||||
'5': BigInteger;
|
||||
'6': BigInteger;
|
||||
'7': BigInteger;
|
||||
'8': BigInteger;
|
||||
'9': BigInteger;
|
||||
'10': BigInteger;
|
||||
'11': BigInteger;
|
||||
'12': BigInteger;
|
||||
'13': BigInteger;
|
||||
'14': BigInteger;
|
||||
'15': BigInteger;
|
||||
'16': BigInteger;
|
||||
'17': BigInteger;
|
||||
'18': BigInteger;
|
||||
'19': BigInteger;
|
||||
'20': BigInteger;
|
||||
'21': BigInteger;
|
||||
'22': BigInteger;
|
||||
'23': BigInteger;
|
||||
'24': BigInteger;
|
||||
'25': BigInteger;
|
||||
'26': BigInteger;
|
||||
'27': BigInteger;
|
||||
'28': BigInteger;
|
||||
'29': BigInteger;
|
||||
'30': BigInteger;
|
||||
'31': BigInteger;
|
||||
'32': BigInteger;
|
||||
'33': BigInteger;
|
||||
'34': BigInteger;
|
||||
'35': BigInteger;
|
||||
'36': BigInteger;
|
||||
'37': BigInteger;
|
||||
'38': BigInteger;
|
||||
'39': BigInteger;
|
||||
'40': BigInteger;
|
||||
'41': BigInteger;
|
||||
'42': BigInteger;
|
||||
'43': BigInteger;
|
||||
'44': BigInteger;
|
||||
'45': BigInteger;
|
||||
'46': BigInteger;
|
||||
'47': BigInteger;
|
||||
'48': BigInteger;
|
||||
'49': BigInteger;
|
||||
'50': BigInteger;
|
||||
'51': BigInteger;
|
||||
'52': BigInteger;
|
||||
'53': BigInteger;
|
||||
'54': BigInteger;
|
||||
'55': BigInteger;
|
||||
'56': BigInteger;
|
||||
'57': BigInteger;
|
||||
'58': BigInteger;
|
||||
'59': BigInteger;
|
||||
'60': BigInteger;
|
||||
'61': BigInteger;
|
||||
'62': BigInteger;
|
||||
'63': BigInteger;
|
||||
'64': BigInteger;
|
||||
'65': BigInteger;
|
||||
'66': BigInteger;
|
||||
'67': BigInteger;
|
||||
'68': BigInteger;
|
||||
'69': BigInteger;
|
||||
'70': BigInteger;
|
||||
'71': BigInteger;
|
||||
'72': BigInteger;
|
||||
'73': BigInteger;
|
||||
'74': BigInteger;
|
||||
'75': BigInteger;
|
||||
'76': BigInteger;
|
||||
'77': BigInteger;
|
||||
'78': BigInteger;
|
||||
'79': BigInteger;
|
||||
'80': BigInteger;
|
||||
'81': BigInteger;
|
||||
'82': BigInteger;
|
||||
'83': BigInteger;
|
||||
'84': BigInteger;
|
||||
'85': BigInteger;
|
||||
'86': BigInteger;
|
||||
'87': BigInteger;
|
||||
'88': BigInteger;
|
||||
'89': BigInteger;
|
||||
'90': BigInteger;
|
||||
'91': BigInteger;
|
||||
'92': BigInteger;
|
||||
'93': BigInteger;
|
||||
'94': BigInteger;
|
||||
'95': BigInteger;
|
||||
'96': BigInteger;
|
||||
'97': BigInteger;
|
||||
'98': BigInteger;
|
||||
'99': BigInteger;
|
||||
'100': BigInteger;
|
||||
'101': BigInteger;
|
||||
'102': BigInteger;
|
||||
'103': BigInteger;
|
||||
'104': BigInteger;
|
||||
'105': BigInteger;
|
||||
'106': BigInteger;
|
||||
'107': BigInteger;
|
||||
'108': BigInteger;
|
||||
'109': BigInteger;
|
||||
'110': BigInteger;
|
||||
'111': BigInteger;
|
||||
'112': BigInteger;
|
||||
'113': BigInteger;
|
||||
'114': BigInteger;
|
||||
'115': BigInteger;
|
||||
'116': BigInteger;
|
||||
'117': BigInteger;
|
||||
'118': BigInteger;
|
||||
'119': BigInteger;
|
||||
'120': BigInteger;
|
||||
'121': BigInteger;
|
||||
'122': BigInteger;
|
||||
'123': BigInteger;
|
||||
'124': BigInteger;
|
||||
'125': BigInteger;
|
||||
'126': BigInteger;
|
||||
'127': BigInteger;
|
||||
'128': BigInteger;
|
||||
'129': BigInteger;
|
||||
'130': BigInteger;
|
||||
'131': BigInteger;
|
||||
'132': BigInteger;
|
||||
'133': BigInteger;
|
||||
'134': BigInteger;
|
||||
'135': BigInteger;
|
||||
'136': BigInteger;
|
||||
'137': BigInteger;
|
||||
'138': BigInteger;
|
||||
'139': BigInteger;
|
||||
'140': BigInteger;
|
||||
'141': BigInteger;
|
||||
'142': BigInteger;
|
||||
'143': BigInteger;
|
||||
'144': BigInteger;
|
||||
'145': BigInteger;
|
||||
'146': BigInteger;
|
||||
'147': BigInteger;
|
||||
'148': BigInteger;
|
||||
'149': BigInteger;
|
||||
'150': BigInteger;
|
||||
'151': BigInteger;
|
||||
'152': BigInteger;
|
||||
'153': BigInteger;
|
||||
'154': BigInteger;
|
||||
'155': BigInteger;
|
||||
'156': BigInteger;
|
||||
'157': BigInteger;
|
||||
'158': BigInteger;
|
||||
'159': BigInteger;
|
||||
'160': BigInteger;
|
||||
'161': BigInteger;
|
||||
'162': BigInteger;
|
||||
'163': BigInteger;
|
||||
'164': BigInteger;
|
||||
'165': BigInteger;
|
||||
'166': BigInteger;
|
||||
'167': BigInteger;
|
||||
'168': BigInteger;
|
||||
'169': BigInteger;
|
||||
'170': BigInteger;
|
||||
'171': BigInteger;
|
||||
'172': BigInteger;
|
||||
'173': BigInteger;
|
||||
'174': BigInteger;
|
||||
'175': BigInteger;
|
||||
'176': BigInteger;
|
||||
'177': BigInteger;
|
||||
'178': BigInteger;
|
||||
'179': BigInteger;
|
||||
'180': BigInteger;
|
||||
'181': BigInteger;
|
||||
'182': BigInteger;
|
||||
'183': BigInteger;
|
||||
'184': BigInteger;
|
||||
'185': BigInteger;
|
||||
'186': BigInteger;
|
||||
'187': BigInteger;
|
||||
'188': BigInteger;
|
||||
'189': BigInteger;
|
||||
'190': BigInteger;
|
||||
'191': BigInteger;
|
||||
'192': BigInteger;
|
||||
'193': BigInteger;
|
||||
'194': BigInteger;
|
||||
'195': BigInteger;
|
||||
'196': BigInteger;
|
||||
'197': BigInteger;
|
||||
'198': BigInteger;
|
||||
'199': BigInteger;
|
||||
'200': BigInteger;
|
||||
'201': BigInteger;
|
||||
'202': BigInteger;
|
||||
'203': BigInteger;
|
||||
'204': BigInteger;
|
||||
'205': BigInteger;
|
||||
'206': BigInteger;
|
||||
'207': BigInteger;
|
||||
'208': BigInteger;
|
||||
'209': BigInteger;
|
||||
'210': BigInteger;
|
||||
'211': BigInteger;
|
||||
'212': BigInteger;
|
||||
'213': BigInteger;
|
||||
'214': BigInteger;
|
||||
'215': BigInteger;
|
||||
'216': BigInteger;
|
||||
'217': BigInteger;
|
||||
'218': BigInteger;
|
||||
'219': BigInteger;
|
||||
'220': BigInteger;
|
||||
'221': BigInteger;
|
||||
'222': BigInteger;
|
||||
'223': BigInteger;
|
||||
'224': BigInteger;
|
||||
'225': BigInteger;
|
||||
'226': BigInteger;
|
||||
'227': BigInteger;
|
||||
'228': BigInteger;
|
||||
'229': BigInteger;
|
||||
'230': BigInteger;
|
||||
'231': BigInteger;
|
||||
'232': BigInteger;
|
||||
'233': BigInteger;
|
||||
'234': BigInteger;
|
||||
'235': BigInteger;
|
||||
'236': BigInteger;
|
||||
'237': BigInteger;
|
||||
'238': BigInteger;
|
||||
'239': BigInteger;
|
||||
'240': BigInteger;
|
||||
'241': BigInteger;
|
||||
'242': BigInteger;
|
||||
'243': BigInteger;
|
||||
'244': BigInteger;
|
||||
'245': BigInteger;
|
||||
'246': BigInteger;
|
||||
'247': BigInteger;
|
||||
'248': BigInteger;
|
||||
'249': BigInteger;
|
||||
'250': BigInteger;
|
||||
'251': BigInteger;
|
||||
'252': BigInteger;
|
||||
'253': BigInteger;
|
||||
'254': BigInteger;
|
||||
'255': BigInteger;
|
||||
'256': BigInteger;
|
||||
'257': BigInteger;
|
||||
'258': BigInteger;
|
||||
'259': BigInteger;
|
||||
'260': BigInteger;
|
||||
'261': BigInteger;
|
||||
'262': BigInteger;
|
||||
'263': BigInteger;
|
||||
'264': BigInteger;
|
||||
'265': BigInteger;
|
||||
'266': BigInteger;
|
||||
'267': BigInteger;
|
||||
'268': BigInteger;
|
||||
'269': BigInteger;
|
||||
'270': BigInteger;
|
||||
'271': BigInteger;
|
||||
'272': BigInteger;
|
||||
'273': BigInteger;
|
||||
'274': BigInteger;
|
||||
'275': BigInteger;
|
||||
'276': BigInteger;
|
||||
'277': BigInteger;
|
||||
'278': BigInteger;
|
||||
'279': BigInteger;
|
||||
'280': BigInteger;
|
||||
'281': BigInteger;
|
||||
'282': BigInteger;
|
||||
'283': BigInteger;
|
||||
'284': BigInteger;
|
||||
'285': BigInteger;
|
||||
'286': BigInteger;
|
||||
'287': BigInteger;
|
||||
'288': BigInteger;
|
||||
'289': BigInteger;
|
||||
'290': BigInteger;
|
||||
'291': BigInteger;
|
||||
'292': BigInteger;
|
||||
'293': BigInteger;
|
||||
'294': BigInteger;
|
||||
'295': BigInteger;
|
||||
'296': BigInteger;
|
||||
'297': BigInteger;
|
||||
'298': BigInteger;
|
||||
'299': BigInteger;
|
||||
'300': BigInteger;
|
||||
'301': BigInteger;
|
||||
'302': BigInteger;
|
||||
'303': BigInteger;
|
||||
'304': BigInteger;
|
||||
'305': BigInteger;
|
||||
'306': BigInteger;
|
||||
'307': BigInteger;
|
||||
'308': BigInteger;
|
||||
'309': BigInteger;
|
||||
'310': BigInteger;
|
||||
'311': BigInteger;
|
||||
'312': BigInteger;
|
||||
'313': BigInteger;
|
||||
'314': BigInteger;
|
||||
'315': BigInteger;
|
||||
'316': BigInteger;
|
||||
'317': BigInteger;
|
||||
'318': BigInteger;
|
||||
'319': BigInteger;
|
||||
'320': BigInteger;
|
||||
'321': BigInteger;
|
||||
'322': BigInteger;
|
||||
'323': BigInteger;
|
||||
'324': BigInteger;
|
||||
'325': BigInteger;
|
||||
'326': BigInteger;
|
||||
'327': BigInteger;
|
||||
'328': BigInteger;
|
||||
'329': BigInteger;
|
||||
'330': BigInteger;
|
||||
'331': BigInteger;
|
||||
'332': BigInteger;
|
||||
'333': BigInteger;
|
||||
'334': BigInteger;
|
||||
'335': BigInteger;
|
||||
'336': BigInteger;
|
||||
'337': BigInteger;
|
||||
'338': BigInteger;
|
||||
'339': BigInteger;
|
||||
'340': BigInteger;
|
||||
'341': BigInteger;
|
||||
'342': BigInteger;
|
||||
'343': BigInteger;
|
||||
'344': BigInteger;
|
||||
'345': BigInteger;
|
||||
'346': BigInteger;
|
||||
'347': BigInteger;
|
||||
'348': BigInteger;
|
||||
'349': BigInteger;
|
||||
'350': BigInteger;
|
||||
'351': BigInteger;
|
||||
'352': BigInteger;
|
||||
'353': BigInteger;
|
||||
'354': BigInteger;
|
||||
'355': BigInteger;
|
||||
'356': BigInteger;
|
||||
'357': BigInteger;
|
||||
'358': BigInteger;
|
||||
'359': BigInteger;
|
||||
'360': BigInteger;
|
||||
'361': BigInteger;
|
||||
'362': BigInteger;
|
||||
'363': BigInteger;
|
||||
'364': BigInteger;
|
||||
'365': BigInteger;
|
||||
'366': BigInteger;
|
||||
'367': BigInteger;
|
||||
'368': BigInteger;
|
||||
'369': BigInteger;
|
||||
'370': BigInteger;
|
||||
'371': BigInteger;
|
||||
'372': BigInteger;
|
||||
'373': BigInteger;
|
||||
'374': BigInteger;
|
||||
'375': BigInteger;
|
||||
'376': BigInteger;
|
||||
'377': BigInteger;
|
||||
'378': BigInteger;
|
||||
'379': BigInteger;
|
||||
'380': BigInteger;
|
||||
'381': BigInteger;
|
||||
'382': BigInteger;
|
||||
'383': BigInteger;
|
||||
'384': BigInteger;
|
||||
'385': BigInteger;
|
||||
'386': BigInteger;
|
||||
'387': BigInteger;
|
||||
'388': BigInteger;
|
||||
'389': BigInteger;
|
||||
'390': BigInteger;
|
||||
'391': BigInteger;
|
||||
'392': BigInteger;
|
||||
'393': BigInteger;
|
||||
'394': BigInteger;
|
||||
'395': BigInteger;
|
||||
'396': BigInteger;
|
||||
'397': BigInteger;
|
||||
'398': BigInteger;
|
||||
'399': BigInteger;
|
||||
'400': BigInteger;
|
||||
'401': BigInteger;
|
||||
'402': BigInteger;
|
||||
'403': BigInteger;
|
||||
'404': BigInteger;
|
||||
'405': BigInteger;
|
||||
'406': BigInteger;
|
||||
'407': BigInteger;
|
||||
'408': BigInteger;
|
||||
'409': BigInteger;
|
||||
'410': BigInteger;
|
||||
'411': BigInteger;
|
||||
'412': BigInteger;
|
||||
'413': BigInteger;
|
||||
'414': BigInteger;
|
||||
'415': BigInteger;
|
||||
'416': BigInteger;
|
||||
'417': BigInteger;
|
||||
'418': BigInteger;
|
||||
'419': BigInteger;
|
||||
'420': BigInteger;
|
||||
'421': BigInteger;
|
||||
'422': BigInteger;
|
||||
'423': BigInteger;
|
||||
'424': BigInteger;
|
||||
'425': BigInteger;
|
||||
'426': BigInteger;
|
||||
'427': BigInteger;
|
||||
'428': BigInteger;
|
||||
'429': BigInteger;
|
||||
'430': BigInteger;
|
||||
'431': BigInteger;
|
||||
'432': BigInteger;
|
||||
'433': BigInteger;
|
||||
'434': BigInteger;
|
||||
'435': BigInteger;
|
||||
'436': BigInteger;
|
||||
'437': BigInteger;
|
||||
'438': BigInteger;
|
||||
'439': BigInteger;
|
||||
'440': BigInteger;
|
||||
'441': BigInteger;
|
||||
'442': BigInteger;
|
||||
'443': BigInteger;
|
||||
'444': BigInteger;
|
||||
'445': BigInteger;
|
||||
'446': BigInteger;
|
||||
'447': BigInteger;
|
||||
'448': BigInteger;
|
||||
'449': BigInteger;
|
||||
'450': BigInteger;
|
||||
'451': BigInteger;
|
||||
'452': BigInteger;
|
||||
'453': BigInteger;
|
||||
'454': BigInteger;
|
||||
'455': BigInteger;
|
||||
'456': BigInteger;
|
||||
'457': BigInteger;
|
||||
'458': BigInteger;
|
||||
'459': BigInteger;
|
||||
'460': BigInteger;
|
||||
'461': BigInteger;
|
||||
'462': BigInteger;
|
||||
'463': BigInteger;
|
||||
'464': BigInteger;
|
||||
'465': BigInteger;
|
||||
'466': BigInteger;
|
||||
'467': BigInteger;
|
||||
'468': BigInteger;
|
||||
'469': BigInteger;
|
||||
'470': BigInteger;
|
||||
'471': BigInteger;
|
||||
'472': BigInteger;
|
||||
'473': BigInteger;
|
||||
'474': BigInteger;
|
||||
'475': BigInteger;
|
||||
'476': BigInteger;
|
||||
'477': BigInteger;
|
||||
'478': BigInteger;
|
||||
'479': BigInteger;
|
||||
'480': BigInteger;
|
||||
'481': BigInteger;
|
||||
'482': BigInteger;
|
||||
'483': BigInteger;
|
||||
'484': BigInteger;
|
||||
'485': BigInteger;
|
||||
'486': BigInteger;
|
||||
'487': BigInteger;
|
||||
'488': BigInteger;
|
||||
'489': BigInteger;
|
||||
'490': BigInteger;
|
||||
'491': BigInteger;
|
||||
'492': BigInteger;
|
||||
'493': BigInteger;
|
||||
'494': BigInteger;
|
||||
'495': BigInteger;
|
||||
'496': BigInteger;
|
||||
'497': BigInteger;
|
||||
'498': BigInteger;
|
||||
'499': BigInteger;
|
||||
'500': BigInteger;
|
||||
'501': BigInteger;
|
||||
'502': BigInteger;
|
||||
'503': BigInteger;
|
||||
'504': BigInteger;
|
||||
'505': BigInteger;
|
||||
'506': BigInteger;
|
||||
'507': BigInteger;
|
||||
'508': BigInteger;
|
||||
'509': BigInteger;
|
||||
'510': BigInteger;
|
||||
'511': BigInteger;
|
||||
'512': BigInteger;
|
||||
'513': BigInteger;
|
||||
'514': BigInteger;
|
||||
'515': BigInteger;
|
||||
'516': BigInteger;
|
||||
'517': BigInteger;
|
||||
'518': BigInteger;
|
||||
'519': BigInteger;
|
||||
'520': BigInteger;
|
||||
'521': BigInteger;
|
||||
'522': BigInteger;
|
||||
'523': BigInteger;
|
||||
'524': BigInteger;
|
||||
'525': BigInteger;
|
||||
'526': BigInteger;
|
||||
'527': BigInteger;
|
||||
'528': BigInteger;
|
||||
'529': BigInteger;
|
||||
'530': BigInteger;
|
||||
'531': BigInteger;
|
||||
'532': BigInteger;
|
||||
'533': BigInteger;
|
||||
'534': BigInteger;
|
||||
'535': BigInteger;
|
||||
'536': BigInteger;
|
||||
'537': BigInteger;
|
||||
'538': BigInteger;
|
||||
'539': BigInteger;
|
||||
'540': BigInteger;
|
||||
'541': BigInteger;
|
||||
'542': BigInteger;
|
||||
'543': BigInteger;
|
||||
'544': BigInteger;
|
||||
'545': BigInteger;
|
||||
'546': BigInteger;
|
||||
'547': BigInteger;
|
||||
'548': BigInteger;
|
||||
'549': BigInteger;
|
||||
'550': BigInteger;
|
||||
'551': BigInteger;
|
||||
'552': BigInteger;
|
||||
'553': BigInteger;
|
||||
'554': BigInteger;
|
||||
'555': BigInteger;
|
||||
'556': BigInteger;
|
||||
'557': BigInteger;
|
||||
'558': BigInteger;
|
||||
'559': BigInteger;
|
||||
'560': BigInteger;
|
||||
'561': BigInteger;
|
||||
'562': BigInteger;
|
||||
'563': BigInteger;
|
||||
'564': BigInteger;
|
||||
'565': BigInteger;
|
||||
'566': BigInteger;
|
||||
'567': BigInteger;
|
||||
'568': BigInteger;
|
||||
'569': BigInteger;
|
||||
'570': BigInteger;
|
||||
'571': BigInteger;
|
||||
'572': BigInteger;
|
||||
'573': BigInteger;
|
||||
'574': BigInteger;
|
||||
'575': BigInteger;
|
||||
'576': BigInteger;
|
||||
'577': BigInteger;
|
||||
'578': BigInteger;
|
||||
'579': BigInteger;
|
||||
'580': BigInteger;
|
||||
'581': BigInteger;
|
||||
'582': BigInteger;
|
||||
'583': BigInteger;
|
||||
'584': BigInteger;
|
||||
'585': BigInteger;
|
||||
'586': BigInteger;
|
||||
'587': BigInteger;
|
||||
'588': BigInteger;
|
||||
'589': BigInteger;
|
||||
'590': BigInteger;
|
||||
'591': BigInteger;
|
||||
'592': BigInteger;
|
||||
'593': BigInteger;
|
||||
'594': BigInteger;
|
||||
'595': BigInteger;
|
||||
'596': BigInteger;
|
||||
'597': BigInteger;
|
||||
'598': BigInteger;
|
||||
'599': BigInteger;
|
||||
'600': BigInteger;
|
||||
'601': BigInteger;
|
||||
'602': BigInteger;
|
||||
'603': BigInteger;
|
||||
'604': BigInteger;
|
||||
'605': BigInteger;
|
||||
'606': BigInteger;
|
||||
'607': BigInteger;
|
||||
'608': BigInteger;
|
||||
'609': BigInteger;
|
||||
'610': BigInteger;
|
||||
'611': BigInteger;
|
||||
'612': BigInteger;
|
||||
'613': BigInteger;
|
||||
'614': BigInteger;
|
||||
'615': BigInteger;
|
||||
'616': BigInteger;
|
||||
'617': BigInteger;
|
||||
'618': BigInteger;
|
||||
'619': BigInteger;
|
||||
'620': BigInteger;
|
||||
'621': BigInteger;
|
||||
'622': BigInteger;
|
||||
'623': BigInteger;
|
||||
'624': BigInteger;
|
||||
'625': BigInteger;
|
||||
'626': BigInteger;
|
||||
'627': BigInteger;
|
||||
'628': BigInteger;
|
||||
'629': BigInteger;
|
||||
'630': BigInteger;
|
||||
'631': BigInteger;
|
||||
'632': BigInteger;
|
||||
'633': BigInteger;
|
||||
'634': BigInteger;
|
||||
'635': BigInteger;
|
||||
'636': BigInteger;
|
||||
'637': BigInteger;
|
||||
'638': BigInteger;
|
||||
'639': BigInteger;
|
||||
'640': BigInteger;
|
||||
'641': BigInteger;
|
||||
'642': BigInteger;
|
||||
'643': BigInteger;
|
||||
'644': BigInteger;
|
||||
'645': BigInteger;
|
||||
'646': BigInteger;
|
||||
'647': BigInteger;
|
||||
'648': BigInteger;
|
||||
'649': BigInteger;
|
||||
'650': BigInteger;
|
||||
'651': BigInteger;
|
||||
'652': BigInteger;
|
||||
'653': BigInteger;
|
||||
'654': BigInteger;
|
||||
'655': BigInteger;
|
||||
'656': BigInteger;
|
||||
'657': BigInteger;
|
||||
'658': BigInteger;
|
||||
'659': BigInteger;
|
||||
'660': BigInteger;
|
||||
'661': BigInteger;
|
||||
'662': BigInteger;
|
||||
'663': BigInteger;
|
||||
'664': BigInteger;
|
||||
'665': BigInteger;
|
||||
'666': BigInteger;
|
||||
'667': BigInteger;
|
||||
'668': BigInteger;
|
||||
'669': BigInteger;
|
||||
'670': BigInteger;
|
||||
'671': BigInteger;
|
||||
'672': BigInteger;
|
||||
'673': BigInteger;
|
||||
'674': BigInteger;
|
||||
'675': BigInteger;
|
||||
'676': BigInteger;
|
||||
'677': BigInteger;
|
||||
'678': BigInteger;
|
||||
'679': BigInteger;
|
||||
'680': BigInteger;
|
||||
'681': BigInteger;
|
||||
'682': BigInteger;
|
||||
'683': BigInteger;
|
||||
'684': BigInteger;
|
||||
'685': BigInteger;
|
||||
'686': BigInteger;
|
||||
'687': BigInteger;
|
||||
'688': BigInteger;
|
||||
'689': BigInteger;
|
||||
'690': BigInteger;
|
||||
'691': BigInteger;
|
||||
'692': BigInteger;
|
||||
'693': BigInteger;
|
||||
'694': BigInteger;
|
||||
'695': BigInteger;
|
||||
'696': BigInteger;
|
||||
'697': BigInteger;
|
||||
'698': BigInteger;
|
||||
'699': BigInteger;
|
||||
'700': BigInteger;
|
||||
'701': BigInteger;
|
||||
'702': BigInteger;
|
||||
'703': BigInteger;
|
||||
'704': BigInteger;
|
||||
'705': BigInteger;
|
||||
'706': BigInteger;
|
||||
'707': BigInteger;
|
||||
'708': BigInteger;
|
||||
'709': BigInteger;
|
||||
'710': BigInteger;
|
||||
'711': BigInteger;
|
||||
'712': BigInteger;
|
||||
'713': BigInteger;
|
||||
'714': BigInteger;
|
||||
'715': BigInteger;
|
||||
'716': BigInteger;
|
||||
'717': BigInteger;
|
||||
'718': BigInteger;
|
||||
'719': BigInteger;
|
||||
'720': BigInteger;
|
||||
'721': BigInteger;
|
||||
'722': BigInteger;
|
||||
'723': BigInteger;
|
||||
'724': BigInteger;
|
||||
'725': BigInteger;
|
||||
'726': BigInteger;
|
||||
'727': BigInteger;
|
||||
'728': BigInteger;
|
||||
'729': BigInteger;
|
||||
'730': BigInteger;
|
||||
'731': BigInteger;
|
||||
'732': BigInteger;
|
||||
'733': BigInteger;
|
||||
'734': BigInteger;
|
||||
'735': BigInteger;
|
||||
'736': BigInteger;
|
||||
'737': BigInteger;
|
||||
'738': BigInteger;
|
||||
'739': BigInteger;
|
||||
'740': BigInteger;
|
||||
'741': BigInteger;
|
||||
'742': BigInteger;
|
||||
'743': BigInteger;
|
||||
'744': BigInteger;
|
||||
'745': BigInteger;
|
||||
'746': BigInteger;
|
||||
'747': BigInteger;
|
||||
'748': BigInteger;
|
||||
'749': BigInteger;
|
||||
'750': BigInteger;
|
||||
'751': BigInteger;
|
||||
'752': BigInteger;
|
||||
'753': BigInteger;
|
||||
'754': BigInteger;
|
||||
'755': BigInteger;
|
||||
'756': BigInteger;
|
||||
'757': BigInteger;
|
||||
'758': BigInteger;
|
||||
'759': BigInteger;
|
||||
'760': BigInteger;
|
||||
'761': BigInteger;
|
||||
'762': BigInteger;
|
||||
'763': BigInteger;
|
||||
'764': BigInteger;
|
||||
'765': BigInteger;
|
||||
'766': BigInteger;
|
||||
'767': BigInteger;
|
||||
'768': BigInteger;
|
||||
'769': BigInteger;
|
||||
'770': BigInteger;
|
||||
'771': BigInteger;
|
||||
'772': BigInteger;
|
||||
'773': BigInteger;
|
||||
'774': BigInteger;
|
||||
'775': BigInteger;
|
||||
'776': BigInteger;
|
||||
'777': BigInteger;
|
||||
'778': BigInteger;
|
||||
'779': BigInteger;
|
||||
'780': BigInteger;
|
||||
'781': BigInteger;
|
||||
'782': BigInteger;
|
||||
'783': BigInteger;
|
||||
'784': BigInteger;
|
||||
'785': BigInteger;
|
||||
'786': BigInteger;
|
||||
'787': BigInteger;
|
||||
'788': BigInteger;
|
||||
'789': BigInteger;
|
||||
'790': BigInteger;
|
||||
'791': BigInteger;
|
||||
'792': BigInteger;
|
||||
'793': BigInteger;
|
||||
'794': BigInteger;
|
||||
'795': BigInteger;
|
||||
'796': BigInteger;
|
||||
'797': BigInteger;
|
||||
'798': BigInteger;
|
||||
'799': BigInteger;
|
||||
'800': BigInteger;
|
||||
'801': BigInteger;
|
||||
'802': BigInteger;
|
||||
'803': BigInteger;
|
||||
'804': BigInteger;
|
||||
'805': BigInteger;
|
||||
'806': BigInteger;
|
||||
'807': BigInteger;
|
||||
'808': BigInteger;
|
||||
'809': BigInteger;
|
||||
'810': BigInteger;
|
||||
'811': BigInteger;
|
||||
'812': BigInteger;
|
||||
'813': BigInteger;
|
||||
'814': BigInteger;
|
||||
'815': BigInteger;
|
||||
'816': BigInteger;
|
||||
'817': BigInteger;
|
||||
'818': BigInteger;
|
||||
'819': BigInteger;
|
||||
'820': BigInteger;
|
||||
'821': BigInteger;
|
||||
'822': BigInteger;
|
||||
'823': BigInteger;
|
||||
'824': BigInteger;
|
||||
'825': BigInteger;
|
||||
'826': BigInteger;
|
||||
'827': BigInteger;
|
||||
'828': BigInteger;
|
||||
'829': BigInteger;
|
||||
'830': BigInteger;
|
||||
'831': BigInteger;
|
||||
'832': BigInteger;
|
||||
'833': BigInteger;
|
||||
'834': BigInteger;
|
||||
'835': BigInteger;
|
||||
'836': BigInteger;
|
||||
'837': BigInteger;
|
||||
'838': BigInteger;
|
||||
'839': BigInteger;
|
||||
'840': BigInteger;
|
||||
'841': BigInteger;
|
||||
'842': BigInteger;
|
||||
'843': BigInteger;
|
||||
'844': BigInteger;
|
||||
'845': BigInteger;
|
||||
'846': BigInteger;
|
||||
'847': BigInteger;
|
||||
'848': BigInteger;
|
||||
'849': BigInteger;
|
||||
'850': BigInteger;
|
||||
'851': BigInteger;
|
||||
'852': BigInteger;
|
||||
'853': BigInteger;
|
||||
'854': BigInteger;
|
||||
'855': BigInteger;
|
||||
'856': BigInteger;
|
||||
'857': BigInteger;
|
||||
'858': BigInteger;
|
||||
'859': BigInteger;
|
||||
'860': BigInteger;
|
||||
'861': BigInteger;
|
||||
'862': BigInteger;
|
||||
'863': BigInteger;
|
||||
'864': BigInteger;
|
||||
'865': BigInteger;
|
||||
'866': BigInteger;
|
||||
'867': BigInteger;
|
||||
'868': BigInteger;
|
||||
'869': BigInteger;
|
||||
'870': BigInteger;
|
||||
'871': BigInteger;
|
||||
'872': BigInteger;
|
||||
'873': BigInteger;
|
||||
'874': BigInteger;
|
||||
'875': BigInteger;
|
||||
'876': BigInteger;
|
||||
'877': BigInteger;
|
||||
'878': BigInteger;
|
||||
'879': BigInteger;
|
||||
'880': BigInteger;
|
||||
'881': BigInteger;
|
||||
'882': BigInteger;
|
||||
'883': BigInteger;
|
||||
'884': BigInteger;
|
||||
'885': BigInteger;
|
||||
'886': BigInteger;
|
||||
'887': BigInteger;
|
||||
'888': BigInteger;
|
||||
'889': BigInteger;
|
||||
'890': BigInteger;
|
||||
'891': BigInteger;
|
||||
'892': BigInteger;
|
||||
'893': BigInteger;
|
||||
'894': BigInteger;
|
||||
'895': BigInteger;
|
||||
'896': BigInteger;
|
||||
'897': BigInteger;
|
||||
'898': BigInteger;
|
||||
'899': BigInteger;
|
||||
'900': BigInteger;
|
||||
'901': BigInteger;
|
||||
'902': BigInteger;
|
||||
'903': BigInteger;
|
||||
'904': BigInteger;
|
||||
'905': BigInteger;
|
||||
'906': BigInteger;
|
||||
'907': BigInteger;
|
||||
'908': BigInteger;
|
||||
'909': BigInteger;
|
||||
'910': BigInteger;
|
||||
'911': BigInteger;
|
||||
'912': BigInteger;
|
||||
'913': BigInteger;
|
||||
'914': BigInteger;
|
||||
'915': BigInteger;
|
||||
'916': BigInteger;
|
||||
'917': BigInteger;
|
||||
'918': BigInteger;
|
||||
'919': BigInteger;
|
||||
'920': BigInteger;
|
||||
'921': BigInteger;
|
||||
'922': BigInteger;
|
||||
'923': BigInteger;
|
||||
'924': BigInteger;
|
||||
'925': BigInteger;
|
||||
'926': BigInteger;
|
||||
'927': BigInteger;
|
||||
'928': BigInteger;
|
||||
'929': BigInteger;
|
||||
'930': BigInteger;
|
||||
'931': BigInteger;
|
||||
'932': BigInteger;
|
||||
'933': BigInteger;
|
||||
'934': BigInteger;
|
||||
'935': BigInteger;
|
||||
'936': BigInteger;
|
||||
'937': BigInteger;
|
||||
'938': BigInteger;
|
||||
'939': BigInteger;
|
||||
'940': BigInteger;
|
||||
'941': BigInteger;
|
||||
'942': BigInteger;
|
||||
'943': BigInteger;
|
||||
'944': BigInteger;
|
||||
'945': BigInteger;
|
||||
'946': BigInteger;
|
||||
'947': BigInteger;
|
||||
'948': BigInteger;
|
||||
'949': BigInteger;
|
||||
'950': BigInteger;
|
||||
'951': BigInteger;
|
||||
'952': BigInteger;
|
||||
'953': BigInteger;
|
||||
'954': BigInteger;
|
||||
'955': BigInteger;
|
||||
'956': BigInteger;
|
||||
'957': BigInteger;
|
||||
'958': BigInteger;
|
||||
'959': BigInteger;
|
||||
'960': BigInteger;
|
||||
'961': BigInteger;
|
||||
'962': BigInteger;
|
||||
'963': BigInteger;
|
||||
'964': BigInteger;
|
||||
'965': BigInteger;
|
||||
'966': BigInteger;
|
||||
'967': BigInteger;
|
||||
'968': BigInteger;
|
||||
'969': BigInteger;
|
||||
'970': BigInteger;
|
||||
'971': BigInteger;
|
||||
'972': BigInteger;
|
||||
'973': BigInteger;
|
||||
'974': BigInteger;
|
||||
'975': BigInteger;
|
||||
'976': BigInteger;
|
||||
'977': BigInteger;
|
||||
'978': BigInteger;
|
||||
'979': BigInteger;
|
||||
'980': BigInteger;
|
||||
'981': BigInteger;
|
||||
'982': BigInteger;
|
||||
'983': BigInteger;
|
||||
'984': BigInteger;
|
||||
'985': BigInteger;
|
||||
'986': BigInteger;
|
||||
'987': BigInteger;
|
||||
'988': BigInteger;
|
||||
'989': BigInteger;
|
||||
'990': BigInteger;
|
||||
'991': BigInteger;
|
||||
'992': BigInteger;
|
||||
'993': BigInteger;
|
||||
'994': BigInteger;
|
||||
'995': BigInteger;
|
||||
'996': BigInteger;
|
||||
'997': BigInteger;
|
||||
'998': BigInteger;
|
||||
'999': BigInteger;
|
||||
}
|
||||
|
||||
interface BaseArray {
|
||||
value: number[],
|
||||
isNegative: boolean
|
||||
}
|
||||
}
|
||||
+1453
@@ -0,0 +1,1453 @@
|
||||
var bigInt = (function (undefined) {
|
||||
"use strict";
|
||||
|
||||
var BASE = 1e7,
|
||||
LOG_BASE = 7,
|
||||
MAX_INT = 9007199254740992,
|
||||
MAX_INT_ARR = smallToArray(MAX_INT),
|
||||
DEFAULT_ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz";
|
||||
|
||||
var supportsNativeBigInt = typeof BigInt === "function";
|
||||
|
||||
function Integer(v, radix, alphabet, caseSensitive) {
|
||||
if (typeof v === "undefined") return Integer[0];
|
||||
if (typeof radix !== "undefined") return +radix === 10 && !alphabet ? parseValue(v) : parseBase(v, radix, alphabet, caseSensitive);
|
||||
return parseValue(v);
|
||||
}
|
||||
|
||||
function BigInteger(value, sign) {
|
||||
this.value = value;
|
||||
this.sign = sign;
|
||||
this.isSmall = false;
|
||||
}
|
||||
BigInteger.prototype = Object.create(Integer.prototype);
|
||||
|
||||
function SmallInteger(value) {
|
||||
this.value = value;
|
||||
this.sign = value < 0;
|
||||
this.isSmall = true;
|
||||
}
|
||||
SmallInteger.prototype = Object.create(Integer.prototype);
|
||||
|
||||
function NativeBigInt(value) {
|
||||
this.value = value;
|
||||
}
|
||||
NativeBigInt.prototype = Object.create(Integer.prototype);
|
||||
|
||||
function isPrecise(n) {
|
||||
return -MAX_INT < n && n < MAX_INT;
|
||||
}
|
||||
|
||||
function smallToArray(n) { // For performance reasons doesn't reference BASE, need to change this function if BASE changes
|
||||
if (n < 1e7)
|
||||
return [n];
|
||||
if (n < 1e14)
|
||||
return [n % 1e7, Math.floor(n / 1e7)];
|
||||
return [n % 1e7, Math.floor(n / 1e7) % 1e7, Math.floor(n / 1e14)];
|
||||
}
|
||||
|
||||
function arrayToSmall(arr) { // If BASE changes this function may need to change
|
||||
trim(arr);
|
||||
var length = arr.length;
|
||||
if (length < 4 && compareAbs(arr, MAX_INT_ARR) < 0) {
|
||||
switch (length) {
|
||||
case 0: return 0;
|
||||
case 1: return arr[0];
|
||||
case 2: return arr[0] + arr[1] * BASE;
|
||||
default: return arr[0] + (arr[1] + arr[2] * BASE) * BASE;
|
||||
}
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
function trim(v) {
|
||||
var i = v.length;
|
||||
while (v[--i] === 0);
|
||||
v.length = i + 1;
|
||||
}
|
||||
|
||||
function createArray(length) { // function shamelessly stolen from Yaffle's library https://github.com/Yaffle/BigInteger
|
||||
var x = new Array(length);
|
||||
var i = -1;
|
||||
while (++i < length) {
|
||||
x[i] = 0;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
function truncate(n) {
|
||||
if (n > 0) return Math.floor(n);
|
||||
return Math.ceil(n);
|
||||
}
|
||||
|
||||
function add(a, b) { // assumes a and b are arrays with a.length >= b.length
|
||||
var l_a = a.length,
|
||||
l_b = b.length,
|
||||
r = new Array(l_a),
|
||||
carry = 0,
|
||||
base = BASE,
|
||||
sum, i;
|
||||
for (i = 0; i < l_b; i++) {
|
||||
sum = a[i] + b[i] + carry;
|
||||
carry = sum >= base ? 1 : 0;
|
||||
r[i] = sum - carry * base;
|
||||
}
|
||||
while (i < l_a) {
|
||||
sum = a[i] + carry;
|
||||
carry = sum === base ? 1 : 0;
|
||||
r[i++] = sum - carry * base;
|
||||
}
|
||||
if (carry > 0) r.push(carry);
|
||||
return r;
|
||||
}
|
||||
|
||||
function addAny(a, b) {
|
||||
if (a.length >= b.length) return add(a, b);
|
||||
return add(b, a);
|
||||
}
|
||||
|
||||
function addSmall(a, carry) { // assumes a is array, carry is number with 0 <= carry < MAX_INT
|
||||
var l = a.length,
|
||||
r = new Array(l),
|
||||
base = BASE,
|
||||
sum, i;
|
||||
for (i = 0; i < l; i++) {
|
||||
sum = a[i] - base + carry;
|
||||
carry = Math.floor(sum / base);
|
||||
r[i] = sum - carry * base;
|
||||
carry += 1;
|
||||
}
|
||||
while (carry > 0) {
|
||||
r[i++] = carry % base;
|
||||
carry = Math.floor(carry / base);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
BigInteger.prototype.add = function (v) {
|
||||
var n = parseValue(v);
|
||||
if (this.sign !== n.sign) {
|
||||
return this.subtract(n.negate());
|
||||
}
|
||||
var a = this.value, b = n.value;
|
||||
if (n.isSmall) {
|
||||
return new BigInteger(addSmall(a, Math.abs(b)), this.sign);
|
||||
}
|
||||
return new BigInteger(addAny(a, b), this.sign);
|
||||
};
|
||||
BigInteger.prototype.plus = BigInteger.prototype.add;
|
||||
|
||||
SmallInteger.prototype.add = function (v) {
|
||||
var n = parseValue(v);
|
||||
var a = this.value;
|
||||
if (a < 0 !== n.sign) {
|
||||
return this.subtract(n.negate());
|
||||
}
|
||||
var b = n.value;
|
||||
if (n.isSmall) {
|
||||
if (isPrecise(a + b)) return new SmallInteger(a + b);
|
||||
b = smallToArray(Math.abs(b));
|
||||
}
|
||||
return new BigInteger(addSmall(b, Math.abs(a)), a < 0);
|
||||
};
|
||||
SmallInteger.prototype.plus = SmallInteger.prototype.add;
|
||||
|
||||
NativeBigInt.prototype.add = function (v) {
|
||||
return new NativeBigInt(this.value + parseValue(v).value);
|
||||
}
|
||||
NativeBigInt.prototype.plus = NativeBigInt.prototype.add;
|
||||
|
||||
function subtract(a, b) { // assumes a and b are arrays with a >= b
|
||||
var a_l = a.length,
|
||||
b_l = b.length,
|
||||
r = new Array(a_l),
|
||||
borrow = 0,
|
||||
base = BASE,
|
||||
i, difference;
|
||||
for (i = 0; i < b_l; i++) {
|
||||
difference = a[i] - borrow - b[i];
|
||||
if (difference < 0) {
|
||||
difference += base;
|
||||
borrow = 1;
|
||||
} else borrow = 0;
|
||||
r[i] = difference;
|
||||
}
|
||||
for (i = b_l; i < a_l; i++) {
|
||||
difference = a[i] - borrow;
|
||||
if (difference < 0) difference += base;
|
||||
else {
|
||||
r[i++] = difference;
|
||||
break;
|
||||
}
|
||||
r[i] = difference;
|
||||
}
|
||||
for (; i < a_l; i++) {
|
||||
r[i] = a[i];
|
||||
}
|
||||
trim(r);
|
||||
return r;
|
||||
}
|
||||
|
||||
function subtractAny(a, b, sign) {
|
||||
var value;
|
||||
if (compareAbs(a, b) >= 0) {
|
||||
value = subtract(a, b);
|
||||
} else {
|
||||
value = subtract(b, a);
|
||||
sign = !sign;
|
||||
}
|
||||
value = arrayToSmall(value);
|
||||
if (typeof value === "number") {
|
||||
if (sign) value = -value;
|
||||
return new SmallInteger(value);
|
||||
}
|
||||
return new BigInteger(value, sign);
|
||||
}
|
||||
|
||||
function subtractSmall(a, b, sign) { // assumes a is array, b is number with 0 <= b < MAX_INT
|
||||
var l = a.length,
|
||||
r = new Array(l),
|
||||
carry = -b,
|
||||
base = BASE,
|
||||
i, difference;
|
||||
for (i = 0; i < l; i++) {
|
||||
difference = a[i] + carry;
|
||||
carry = Math.floor(difference / base);
|
||||
difference %= base;
|
||||
r[i] = difference < 0 ? difference + base : difference;
|
||||
}
|
||||
r = arrayToSmall(r);
|
||||
if (typeof r === "number") {
|
||||
if (sign) r = -r;
|
||||
return new SmallInteger(r);
|
||||
} return new BigInteger(r, sign);
|
||||
}
|
||||
|
||||
BigInteger.prototype.subtract = function (v) {
|
||||
var n = parseValue(v);
|
||||
if (this.sign !== n.sign) {
|
||||
return this.add(n.negate());
|
||||
}
|
||||
var a = this.value, b = n.value;
|
||||
if (n.isSmall)
|
||||
return subtractSmall(a, Math.abs(b), this.sign);
|
||||
return subtractAny(a, b, this.sign);
|
||||
};
|
||||
BigInteger.prototype.minus = BigInteger.prototype.subtract;
|
||||
|
||||
SmallInteger.prototype.subtract = function (v) {
|
||||
var n = parseValue(v);
|
||||
var a = this.value;
|
||||
if (a < 0 !== n.sign) {
|
||||
return this.add(n.negate());
|
||||
}
|
||||
var b = n.value;
|
||||
if (n.isSmall) {
|
||||
return new SmallInteger(a - b);
|
||||
}
|
||||
return subtractSmall(b, Math.abs(a), a >= 0);
|
||||
};
|
||||
SmallInteger.prototype.minus = SmallInteger.prototype.subtract;
|
||||
|
||||
NativeBigInt.prototype.subtract = function (v) {
|
||||
return new NativeBigInt(this.value - parseValue(v).value);
|
||||
}
|
||||
NativeBigInt.prototype.minus = NativeBigInt.prototype.subtract;
|
||||
|
||||
BigInteger.prototype.negate = function () {
|
||||
return new BigInteger(this.value, !this.sign);
|
||||
};
|
||||
SmallInteger.prototype.negate = function () {
|
||||
var sign = this.sign;
|
||||
var small = new SmallInteger(-this.value);
|
||||
small.sign = !sign;
|
||||
return small;
|
||||
};
|
||||
NativeBigInt.prototype.negate = function () {
|
||||
return new NativeBigInt(-this.value);
|
||||
}
|
||||
|
||||
BigInteger.prototype.abs = function () {
|
||||
return new BigInteger(this.value, false);
|
||||
};
|
||||
SmallInteger.prototype.abs = function () {
|
||||
return new SmallInteger(Math.abs(this.value));
|
||||
};
|
||||
NativeBigInt.prototype.abs = function () {
|
||||
return new NativeBigInt(this.value >= 0 ? this.value : -this.value);
|
||||
}
|
||||
|
||||
|
||||
function multiplyLong(a, b) {
|
||||
var a_l = a.length,
|
||||
b_l = b.length,
|
||||
l = a_l + b_l,
|
||||
r = createArray(l),
|
||||
base = BASE,
|
||||
product, carry, i, a_i, b_j;
|
||||
for (i = 0; i < a_l; ++i) {
|
||||
a_i = a[i];
|
||||
for (var j = 0; j < b_l; ++j) {
|
||||
b_j = b[j];
|
||||
product = a_i * b_j + r[i + j];
|
||||
carry = Math.floor(product / base);
|
||||
r[i + j] = product - carry * base;
|
||||
r[i + j + 1] += carry;
|
||||
}
|
||||
}
|
||||
trim(r);
|
||||
return r;
|
||||
}
|
||||
|
||||
function multiplySmall(a, b) { // assumes a is array, b is number with |b| < BASE
|
||||
var l = a.length,
|
||||
r = new Array(l),
|
||||
base = BASE,
|
||||
carry = 0,
|
||||
product, i;
|
||||
for (i = 0; i < l; i++) {
|
||||
product = a[i] * b + carry;
|
||||
carry = Math.floor(product / base);
|
||||
r[i] = product - carry * base;
|
||||
}
|
||||
while (carry > 0) {
|
||||
r[i++] = carry % base;
|
||||
carry = Math.floor(carry / base);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
function shiftLeft(x, n) {
|
||||
var r = [];
|
||||
while (n-- > 0) r.push(0);
|
||||
return r.concat(x);
|
||||
}
|
||||
|
||||
function multiplyKaratsuba(x, y) {
|
||||
var n = Math.max(x.length, y.length);
|
||||
|
||||
if (n <= 30) return multiplyLong(x, y);
|
||||
n = Math.ceil(n / 2);
|
||||
|
||||
var b = x.slice(n),
|
||||
a = x.slice(0, n),
|
||||
d = y.slice(n),
|
||||
c = y.slice(0, n);
|
||||
|
||||
var ac = multiplyKaratsuba(a, c),
|
||||
bd = multiplyKaratsuba(b, d),
|
||||
abcd = multiplyKaratsuba(addAny(a, b), addAny(c, d));
|
||||
|
||||
var product = addAny(addAny(ac, shiftLeft(subtract(subtract(abcd, ac), bd), n)), shiftLeft(bd, 2 * n));
|
||||
trim(product);
|
||||
return product;
|
||||
}
|
||||
|
||||
// The following function is derived from a surface fit of a graph plotting the performance difference
|
||||
// between long multiplication and karatsuba multiplication versus the lengths of the two arrays.
|
||||
function useKaratsuba(l1, l2) {
|
||||
return -0.012 * l1 - 0.012 * l2 + 0.000015 * l1 * l2 > 0;
|
||||
}
|
||||
|
||||
BigInteger.prototype.multiply = function (v) {
|
||||
var n = parseValue(v),
|
||||
a = this.value, b = n.value,
|
||||
sign = this.sign !== n.sign,
|
||||
abs;
|
||||
if (n.isSmall) {
|
||||
if (b === 0) return Integer[0];
|
||||
if (b === 1) return this;
|
||||
if (b === -1) return this.negate();
|
||||
abs = Math.abs(b);
|
||||
if (abs < BASE) {
|
||||
return new BigInteger(multiplySmall(a, abs), sign);
|
||||
}
|
||||
b = smallToArray(abs);
|
||||
}
|
||||
if (useKaratsuba(a.length, b.length)) // Karatsuba is only faster for certain array sizes
|
||||
return new BigInteger(multiplyKaratsuba(a, b), sign);
|
||||
return new BigInteger(multiplyLong(a, b), sign);
|
||||
};
|
||||
|
||||
BigInteger.prototype.times = BigInteger.prototype.multiply;
|
||||
|
||||
function multiplySmallAndArray(a, b, sign) { // a >= 0
|
||||
if (a < BASE) {
|
||||
return new BigInteger(multiplySmall(b, a), sign);
|
||||
}
|
||||
return new BigInteger(multiplyLong(b, smallToArray(a)), sign);
|
||||
}
|
||||
SmallInteger.prototype._multiplyBySmall = function (a) {
|
||||
if (isPrecise(a.value * this.value)) {
|
||||
return new SmallInteger(a.value * this.value);
|
||||
}
|
||||
return multiplySmallAndArray(Math.abs(a.value), smallToArray(Math.abs(this.value)), this.sign !== a.sign);
|
||||
};
|
||||
BigInteger.prototype._multiplyBySmall = function (a) {
|
||||
if (a.value === 0) return Integer[0];
|
||||
if (a.value === 1) return this;
|
||||
if (a.value === -1) return this.negate();
|
||||
return multiplySmallAndArray(Math.abs(a.value), this.value, this.sign !== a.sign);
|
||||
};
|
||||
SmallInteger.prototype.multiply = function (v) {
|
||||
return parseValue(v)._multiplyBySmall(this);
|
||||
};
|
||||
SmallInteger.prototype.times = SmallInteger.prototype.multiply;
|
||||
|
||||
NativeBigInt.prototype.multiply = function (v) {
|
||||
return new NativeBigInt(this.value * parseValue(v).value);
|
||||
}
|
||||
NativeBigInt.prototype.times = NativeBigInt.prototype.multiply;
|
||||
|
||||
function square(a) {
|
||||
//console.assert(2 * BASE * BASE < MAX_INT);
|
||||
var l = a.length,
|
||||
r = createArray(l + l),
|
||||
base = BASE,
|
||||
product, carry, i, a_i, a_j;
|
||||
for (i = 0; i < l; i++) {
|
||||
a_i = a[i];
|
||||
carry = 0 - a_i * a_i;
|
||||
for (var j = i; j < l; j++) {
|
||||
a_j = a[j];
|
||||
product = 2 * (a_i * a_j) + r[i + j] + carry;
|
||||
carry = Math.floor(product / base);
|
||||
r[i + j] = product - carry * base;
|
||||
}
|
||||
r[i + l] = carry;
|
||||
}
|
||||
trim(r);
|
||||
return r;
|
||||
}
|
||||
|
||||
BigInteger.prototype.square = function () {
|
||||
return new BigInteger(square(this.value), false);
|
||||
};
|
||||
|
||||
SmallInteger.prototype.square = function () {
|
||||
var value = this.value * this.value;
|
||||
if (isPrecise(value)) return new SmallInteger(value);
|
||||
return new BigInteger(square(smallToArray(Math.abs(this.value))), false);
|
||||
};
|
||||
|
||||
NativeBigInt.prototype.square = function (v) {
|
||||
return new NativeBigInt(this.value * this.value);
|
||||
}
|
||||
|
||||
function divMod1(a, b) { // Left over from previous version. Performs faster than divMod2 on smaller input sizes.
|
||||
var a_l = a.length,
|
||||
b_l = b.length,
|
||||
base = BASE,
|
||||
result = createArray(b.length),
|
||||
divisorMostSignificantDigit = b[b_l - 1],
|
||||
// normalization
|
||||
lambda = Math.ceil(base / (2 * divisorMostSignificantDigit)),
|
||||
remainder = multiplySmall(a, lambda),
|
||||
divisor = multiplySmall(b, lambda),
|
||||
quotientDigit, shift, carry, borrow, i, l, q;
|
||||
if (remainder.length <= a_l) remainder.push(0);
|
||||
divisor.push(0);
|
||||
divisorMostSignificantDigit = divisor[b_l - 1];
|
||||
for (shift = a_l - b_l; shift >= 0; shift--) {
|
||||
quotientDigit = base - 1;
|
||||
if (remainder[shift + b_l] !== divisorMostSignificantDigit) {
|
||||
quotientDigit = Math.floor((remainder[shift + b_l] * base + remainder[shift + b_l - 1]) / divisorMostSignificantDigit);
|
||||
}
|
||||
// quotientDigit <= base - 1
|
||||
carry = 0;
|
||||
borrow = 0;
|
||||
l = divisor.length;
|
||||
for (i = 0; i < l; i++) {
|
||||
carry += quotientDigit * divisor[i];
|
||||
q = Math.floor(carry / base);
|
||||
borrow += remainder[shift + i] - (carry - q * base);
|
||||
carry = q;
|
||||
if (borrow < 0) {
|
||||
remainder[shift + i] = borrow + base;
|
||||
borrow = -1;
|
||||
} else {
|
||||
remainder[shift + i] = borrow;
|
||||
borrow = 0;
|
||||
}
|
||||
}
|
||||
while (borrow !== 0) {
|
||||
quotientDigit -= 1;
|
||||
carry = 0;
|
||||
for (i = 0; i < l; i++) {
|
||||
carry += remainder[shift + i] - base + divisor[i];
|
||||
if (carry < 0) {
|
||||
remainder[shift + i] = carry + base;
|
||||
carry = 0;
|
||||
} else {
|
||||
remainder[shift + i] = carry;
|
||||
carry = 1;
|
||||
}
|
||||
}
|
||||
borrow += carry;
|
||||
}
|
||||
result[shift] = quotientDigit;
|
||||
}
|
||||
// denormalization
|
||||
remainder = divModSmall(remainder, lambda)[0];
|
||||
return [arrayToSmall(result), arrayToSmall(remainder)];
|
||||
}
|
||||
|
||||
function divMod2(a, b) { // Implementation idea shamelessly stolen from Silent Matt's library http://silentmatt.com/biginteger/
|
||||
// Performs faster than divMod1 on larger input sizes.
|
||||
var a_l = a.length,
|
||||
b_l = b.length,
|
||||
result = [],
|
||||
part = [],
|
||||
base = BASE,
|
||||
guess, xlen, highx, highy, check;
|
||||
while (a_l) {
|
||||
part.unshift(a[--a_l]);
|
||||
trim(part);
|
||||
if (compareAbs(part, b) < 0) {
|
||||
result.push(0);
|
||||
continue;
|
||||
}
|
||||
xlen = part.length;
|
||||
highx = part[xlen - 1] * base + part[xlen - 2];
|
||||
highy = b[b_l - 1] * base + b[b_l - 2];
|
||||
if (xlen > b_l) {
|
||||
highx = (highx + 1) * base;
|
||||
}
|
||||
guess = Math.ceil(highx / highy);
|
||||
do {
|
||||
check = multiplySmall(b, guess);
|
||||
if (compareAbs(check, part) <= 0) break;
|
||||
guess--;
|
||||
} while (guess);
|
||||
result.push(guess);
|
||||
part = subtract(part, check);
|
||||
}
|
||||
result.reverse();
|
||||
return [arrayToSmall(result), arrayToSmall(part)];
|
||||
}
|
||||
|
||||
function divModSmall(value, lambda) {
|
||||
var length = value.length,
|
||||
quotient = createArray(length),
|
||||
base = BASE,
|
||||
i, q, remainder, divisor;
|
||||
remainder = 0;
|
||||
for (i = length - 1; i >= 0; --i) {
|
||||
divisor = remainder * base + value[i];
|
||||
q = truncate(divisor / lambda);
|
||||
remainder = divisor - q * lambda;
|
||||
quotient[i] = q | 0;
|
||||
}
|
||||
return [quotient, remainder | 0];
|
||||
}
|
||||
|
||||
function divModAny(self, v) {
|
||||
var value, n = parseValue(v);
|
||||
if (supportsNativeBigInt) {
|
||||
return [new NativeBigInt(self.value / n.value), new NativeBigInt(self.value % n.value)];
|
||||
}
|
||||
var a = self.value, b = n.value;
|
||||
var quotient;
|
||||
if (b === 0) throw new Error("Cannot divide by zero");
|
||||
if (self.isSmall) {
|
||||
if (n.isSmall) {
|
||||
return [new SmallInteger(truncate(a / b)), new SmallInteger(a % b)];
|
||||
}
|
||||
return [Integer[0], self];
|
||||
}
|
||||
if (n.isSmall) {
|
||||
if (b === 1) return [self, Integer[0]];
|
||||
if (b == -1) return [self.negate(), Integer[0]];
|
||||
var abs = Math.abs(b);
|
||||
if (abs < BASE) {
|
||||
value = divModSmall(a, abs);
|
||||
quotient = arrayToSmall(value[0]);
|
||||
var remainder = value[1];
|
||||
if (self.sign) remainder = -remainder;
|
||||
if (typeof quotient === "number") {
|
||||
if (self.sign !== n.sign) quotient = -quotient;
|
||||
return [new SmallInteger(quotient), new SmallInteger(remainder)];
|
||||
}
|
||||
return [new BigInteger(quotient, self.sign !== n.sign), new SmallInteger(remainder)];
|
||||
}
|
||||
b = smallToArray(abs);
|
||||
}
|
||||
var comparison = compareAbs(a, b);
|
||||
if (comparison === -1) return [Integer[0], self];
|
||||
if (comparison === 0) return [Integer[self.sign === n.sign ? 1 : -1], Integer[0]];
|
||||
|
||||
// divMod1 is faster on smaller input sizes
|
||||
if (a.length + b.length <= 200)
|
||||
value = divMod1(a, b);
|
||||
else value = divMod2(a, b);
|
||||
|
||||
quotient = value[0];
|
||||
var qSign = self.sign !== n.sign,
|
||||
mod = value[1],
|
||||
mSign = self.sign;
|
||||
if (typeof quotient === "number") {
|
||||
if (qSign) quotient = -quotient;
|
||||
quotient = new SmallInteger(quotient);
|
||||
} else quotient = new BigInteger(quotient, qSign);
|
||||
if (typeof mod === "number") {
|
||||
if (mSign) mod = -mod;
|
||||
mod = new SmallInteger(mod);
|
||||
} else mod = new BigInteger(mod, mSign);
|
||||
return [quotient, mod];
|
||||
}
|
||||
|
||||
BigInteger.prototype.divmod = function (v) {
|
||||
var result = divModAny(this, v);
|
||||
return {
|
||||
quotient: result[0],
|
||||
remainder: result[1]
|
||||
};
|
||||
};
|
||||
NativeBigInt.prototype.divmod = SmallInteger.prototype.divmod = BigInteger.prototype.divmod;
|
||||
|
||||
|
||||
BigInteger.prototype.divide = function (v) {
|
||||
return divModAny(this, v)[0];
|
||||
};
|
||||
NativeBigInt.prototype.over = NativeBigInt.prototype.divide = function (v) {
|
||||
return new NativeBigInt(this.value / parseValue(v).value);
|
||||
};
|
||||
SmallInteger.prototype.over = SmallInteger.prototype.divide = BigInteger.prototype.over = BigInteger.prototype.divide;
|
||||
|
||||
BigInteger.prototype.mod = function (v) {
|
||||
return divModAny(this, v)[1];
|
||||
};
|
||||
NativeBigInt.prototype.mod = NativeBigInt.prototype.remainder = function (v) {
|
||||
return new NativeBigInt(this.value % parseValue(v).value);
|
||||
};
|
||||
SmallInteger.prototype.remainder = SmallInteger.prototype.mod = BigInteger.prototype.remainder = BigInteger.prototype.mod;
|
||||
|
||||
BigInteger.prototype.pow = function (v) {
|
||||
var n = parseValue(v),
|
||||
a = this.value,
|
||||
b = n.value,
|
||||
value, x, y;
|
||||
if (b === 0) return Integer[1];
|
||||
if (a === 0) return Integer[0];
|
||||
if (a === 1) return Integer[1];
|
||||
if (a === -1) return n.isEven() ? Integer[1] : Integer[-1];
|
||||
if (n.sign) {
|
||||
return Integer[0];
|
||||
}
|
||||
if (!n.isSmall) throw new Error("The exponent " + n.toString() + " is too large.");
|
||||
if (this.isSmall) {
|
||||
if (isPrecise(value = Math.pow(a, b)))
|
||||
return new SmallInteger(truncate(value));
|
||||
}
|
||||
x = this;
|
||||
y = Integer[1];
|
||||
while (true) {
|
||||
if (b & 1 === 1) {
|
||||
y = y.times(x);
|
||||
--b;
|
||||
}
|
||||
if (b === 0) break;
|
||||
b /= 2;
|
||||
x = x.square();
|
||||
}
|
||||
return y;
|
||||
};
|
||||
SmallInteger.prototype.pow = BigInteger.prototype.pow;
|
||||
|
||||
NativeBigInt.prototype.pow = function (v) {
|
||||
var n = parseValue(v);
|
||||
var a = this.value, b = n.value;
|
||||
var _0 = BigInt(0), _1 = BigInt(1), _2 = BigInt(2);
|
||||
if (b === _0) return Integer[1];
|
||||
if (a === _0) return Integer[0];
|
||||
if (a === _1) return Integer[1];
|
||||
if (a === BigInt(-1)) return n.isEven() ? Integer[1] : Integer[-1];
|
||||
if (n.isNegative()) return new NativeBigInt(_0);
|
||||
var x = this;
|
||||
var y = Integer[1];
|
||||
while (true) {
|
||||
if ((b & _1) === _1) {
|
||||
y = y.times(x);
|
||||
--b;
|
||||
}
|
||||
if (b === _0) break;
|
||||
b /= _2;
|
||||
x = x.square();
|
||||
}
|
||||
return y;
|
||||
}
|
||||
|
||||
BigInteger.prototype.modPow = function (exp, mod) {
|
||||
exp = parseValue(exp);
|
||||
mod = parseValue(mod);
|
||||
if (mod.isZero()) throw new Error("Cannot take modPow with modulus 0");
|
||||
var r = Integer[1],
|
||||
base = this.mod(mod);
|
||||
if (exp.isNegative()) {
|
||||
exp = exp.multiply(Integer[-1]);
|
||||
base = base.modInv(mod);
|
||||
}
|
||||
while (exp.isPositive()) {
|
||||
if (base.isZero()) return Integer[0];
|
||||
if (exp.isOdd()) r = r.multiply(base).mod(mod);
|
||||
exp = exp.divide(2);
|
||||
base = base.square().mod(mod);
|
||||
}
|
||||
return r;
|
||||
};
|
||||
NativeBigInt.prototype.modPow = SmallInteger.prototype.modPow = BigInteger.prototype.modPow;
|
||||
|
||||
function compareAbs(a, b) {
|
||||
if (a.length !== b.length) {
|
||||
return a.length > b.length ? 1 : -1;
|
||||
}
|
||||
for (var i = a.length - 1; i >= 0; i--) {
|
||||
if (a[i] !== b[i]) return a[i] > b[i] ? 1 : -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
BigInteger.prototype.compareAbs = function (v) {
|
||||
var n = parseValue(v),
|
||||
a = this.value,
|
||||
b = n.value;
|
||||
if (n.isSmall) return 1;
|
||||
return compareAbs(a, b);
|
||||
};
|
||||
SmallInteger.prototype.compareAbs = function (v) {
|
||||
var n = parseValue(v),
|
||||
a = Math.abs(this.value),
|
||||
b = n.value;
|
||||
if (n.isSmall) {
|
||||
b = Math.abs(b);
|
||||
return a === b ? 0 : a > b ? 1 : -1;
|
||||
}
|
||||
return -1;
|
||||
};
|
||||
NativeBigInt.prototype.compareAbs = function (v) {
|
||||
var a = this.value;
|
||||
var b = parseValue(v).value;
|
||||
a = a >= 0 ? a : -a;
|
||||
b = b >= 0 ? b : -b;
|
||||
return a === b ? 0 : a > b ? 1 : -1;
|
||||
}
|
||||
|
||||
BigInteger.prototype.compare = function (v) {
|
||||
// See discussion about comparison with Infinity:
|
||||
// https://github.com/peterolson/BigInteger.js/issues/61
|
||||
if (v === Infinity) {
|
||||
return -1;
|
||||
}
|
||||
if (v === -Infinity) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
var n = parseValue(v),
|
||||
a = this.value,
|
||||
b = n.value;
|
||||
if (this.sign !== n.sign) {
|
||||
return n.sign ? 1 : -1;
|
||||
}
|
||||
if (n.isSmall) {
|
||||
return this.sign ? -1 : 1;
|
||||
}
|
||||
return compareAbs(a, b) * (this.sign ? -1 : 1);
|
||||
};
|
||||
BigInteger.prototype.compareTo = BigInteger.prototype.compare;
|
||||
|
||||
SmallInteger.prototype.compare = function (v) {
|
||||
if (v === Infinity) {
|
||||
return -1;
|
||||
}
|
||||
if (v === -Infinity) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
var n = parseValue(v),
|
||||
a = this.value,
|
||||
b = n.value;
|
||||
if (n.isSmall) {
|
||||
return a == b ? 0 : a > b ? 1 : -1;
|
||||
}
|
||||
if (a < 0 !== n.sign) {
|
||||
return a < 0 ? -1 : 1;
|
||||
}
|
||||
return a < 0 ? 1 : -1;
|
||||
};
|
||||
SmallInteger.prototype.compareTo = SmallInteger.prototype.compare;
|
||||
|
||||
NativeBigInt.prototype.compare = function (v) {
|
||||
if (v === Infinity) {
|
||||
return -1;
|
||||
}
|
||||
if (v === -Infinity) {
|
||||
return 1;
|
||||
}
|
||||
var a = this.value;
|
||||
var b = parseValue(v).value;
|
||||
return a === b ? 0 : a > b ? 1 : -1;
|
||||
}
|
||||
NativeBigInt.prototype.compareTo = NativeBigInt.prototype.compare;
|
||||
|
||||
BigInteger.prototype.equals = function (v) {
|
||||
return this.compare(v) === 0;
|
||||
};
|
||||
NativeBigInt.prototype.eq = NativeBigInt.prototype.equals = SmallInteger.prototype.eq = SmallInteger.prototype.equals = BigInteger.prototype.eq = BigInteger.prototype.equals;
|
||||
|
||||
BigInteger.prototype.notEquals = function (v) {
|
||||
return this.compare(v) !== 0;
|
||||
};
|
||||
NativeBigInt.prototype.neq = NativeBigInt.prototype.notEquals = SmallInteger.prototype.neq = SmallInteger.prototype.notEquals = BigInteger.prototype.neq = BigInteger.prototype.notEquals;
|
||||
|
||||
BigInteger.prototype.greater = function (v) {
|
||||
return this.compare(v) > 0;
|
||||
};
|
||||
NativeBigInt.prototype.gt = NativeBigInt.prototype.greater = SmallInteger.prototype.gt = SmallInteger.prototype.greater = BigInteger.prototype.gt = BigInteger.prototype.greater;
|
||||
|
||||
BigInteger.prototype.lesser = function (v) {
|
||||
return this.compare(v) < 0;
|
||||
};
|
||||
NativeBigInt.prototype.lt = NativeBigInt.prototype.lesser = SmallInteger.prototype.lt = SmallInteger.prototype.lesser = BigInteger.prototype.lt = BigInteger.prototype.lesser;
|
||||
|
||||
BigInteger.prototype.greaterOrEquals = function (v) {
|
||||
return this.compare(v) >= 0;
|
||||
};
|
||||
NativeBigInt.prototype.geq = NativeBigInt.prototype.greaterOrEquals = SmallInteger.prototype.geq = SmallInteger.prototype.greaterOrEquals = BigInteger.prototype.geq = BigInteger.prototype.greaterOrEquals;
|
||||
|
||||
BigInteger.prototype.lesserOrEquals = function (v) {
|
||||
return this.compare(v) <= 0;
|
||||
};
|
||||
NativeBigInt.prototype.leq = NativeBigInt.prototype.lesserOrEquals = SmallInteger.prototype.leq = SmallInteger.prototype.lesserOrEquals = BigInteger.prototype.leq = BigInteger.prototype.lesserOrEquals;
|
||||
|
||||
BigInteger.prototype.isEven = function () {
|
||||
return (this.value[0] & 1) === 0;
|
||||
};
|
||||
SmallInteger.prototype.isEven = function () {
|
||||
return (this.value & 1) === 0;
|
||||
};
|
||||
NativeBigInt.prototype.isEven = function () {
|
||||
return (this.value & BigInt(1)) === BigInt(0);
|
||||
}
|
||||
|
||||
BigInteger.prototype.isOdd = function () {
|
||||
return (this.value[0] & 1) === 1;
|
||||
};
|
||||
SmallInteger.prototype.isOdd = function () {
|
||||
return (this.value & 1) === 1;
|
||||
};
|
||||
NativeBigInt.prototype.isOdd = function () {
|
||||
return (this.value & BigInt(1)) === BigInt(1);
|
||||
}
|
||||
|
||||
BigInteger.prototype.isPositive = function () {
|
||||
return !this.sign;
|
||||
};
|
||||
SmallInteger.prototype.isPositive = function () {
|
||||
return this.value > 0;
|
||||
};
|
||||
NativeBigInt.prototype.isPositive = SmallInteger.prototype.isPositive;
|
||||
|
||||
BigInteger.prototype.isNegative = function () {
|
||||
return this.sign;
|
||||
};
|
||||
SmallInteger.prototype.isNegative = function () {
|
||||
return this.value < 0;
|
||||
};
|
||||
NativeBigInt.prototype.isNegative = SmallInteger.prototype.isNegative;
|
||||
|
||||
BigInteger.prototype.isUnit = function () {
|
||||
return false;
|
||||
};
|
||||
SmallInteger.prototype.isUnit = function () {
|
||||
return Math.abs(this.value) === 1;
|
||||
};
|
||||
NativeBigInt.prototype.isUnit = function () {
|
||||
return this.abs().value === BigInt(1);
|
||||
}
|
||||
|
||||
BigInteger.prototype.isZero = function () {
|
||||
return false;
|
||||
};
|
||||
SmallInteger.prototype.isZero = function () {
|
||||
return this.value === 0;
|
||||
};
|
||||
NativeBigInt.prototype.isZero = function () {
|
||||
return this.value === BigInt(0);
|
||||
}
|
||||
|
||||
BigInteger.prototype.isDivisibleBy = function (v) {
|
||||
var n = parseValue(v);
|
||||
if (n.isZero()) return false;
|
||||
if (n.isUnit()) return true;
|
||||
if (n.compareAbs(2) === 0) return this.isEven();
|
||||
return this.mod(n).isZero();
|
||||
};
|
||||
NativeBigInt.prototype.isDivisibleBy = SmallInteger.prototype.isDivisibleBy = BigInteger.prototype.isDivisibleBy;
|
||||
|
||||
function isBasicPrime(v) {
|
||||
var n = v.abs();
|
||||
if (n.isUnit()) return false;
|
||||
if (n.equals(2) || n.equals(3) || n.equals(5)) return true;
|
||||
if (n.isEven() || n.isDivisibleBy(3) || n.isDivisibleBy(5)) return false;
|
||||
if (n.lesser(49)) return true;
|
||||
// we don't know if it's prime: let the other functions figure it out
|
||||
}
|
||||
|
||||
function millerRabinTest(n, a) {
|
||||
var nPrev = n.prev(),
|
||||
b = nPrev,
|
||||
r = 0,
|
||||
d, t, i, x;
|
||||
while (b.isEven()) b = b.divide(2), r++;
|
||||
next: for (i = 0; i < a.length; i++) {
|
||||
if (n.lesser(a[i])) continue;
|
||||
x = bigInt(a[i]).modPow(b, n);
|
||||
if (x.isUnit() || x.equals(nPrev)) continue;
|
||||
for (d = r - 1; d != 0; d--) {
|
||||
x = x.square().mod(n);
|
||||
if (x.isUnit()) return false;
|
||||
if (x.equals(nPrev)) continue next;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Set "strict" to true to force GRH-supported lower bound of 2*log(N)^2
|
||||
BigInteger.prototype.isPrime = function (strict) {
|
||||
var isPrime = isBasicPrime(this);
|
||||
if (isPrime !== undefined) return isPrime;
|
||||
var n = this.abs();
|
||||
var bits = n.bitLength();
|
||||
if (bits <= 64)
|
||||
return millerRabinTest(n, [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]);
|
||||
var logN = Math.log(2) * bits.toJSNumber();
|
||||
var t = Math.ceil((strict === true) ? (2 * Math.pow(logN, 2)) : logN);
|
||||
for (var a = [], i = 0; i < t; i++) {
|
||||
a.push(bigInt(i + 2));
|
||||
}
|
||||
return millerRabinTest(n, a);
|
||||
};
|
||||
NativeBigInt.prototype.isPrime = SmallInteger.prototype.isPrime = BigInteger.prototype.isPrime;
|
||||
|
||||
BigInteger.prototype.isProbablePrime = function (iterations, rng) {
|
||||
var isPrime = isBasicPrime(this);
|
||||
if (isPrime !== undefined) return isPrime;
|
||||
var n = this.abs();
|
||||
var t = iterations === undefined ? 5 : iterations;
|
||||
for (var a = [], i = 0; i < t; i++) {
|
||||
a.push(bigInt.randBetween(2, n.minus(2), rng));
|
||||
}
|
||||
return millerRabinTest(n, a);
|
||||
};
|
||||
NativeBigInt.prototype.isProbablePrime = SmallInteger.prototype.isProbablePrime = BigInteger.prototype.isProbablePrime;
|
||||
|
||||
BigInteger.prototype.modInv = function (n) {
|
||||
var t = bigInt.zero, newT = bigInt.one, r = parseValue(n), newR = this.abs(), q, lastT, lastR;
|
||||
while (!newR.isZero()) {
|
||||
q = r.divide(newR);
|
||||
lastT = t;
|
||||
lastR = r;
|
||||
t = newT;
|
||||
r = newR;
|
||||
newT = lastT.subtract(q.multiply(newT));
|
||||
newR = lastR.subtract(q.multiply(newR));
|
||||
}
|
||||
if (!r.isUnit()) throw new Error(this.toString() + " and " + n.toString() + " are not co-prime");
|
||||
if (t.compare(0) === -1) {
|
||||
t = t.add(n);
|
||||
}
|
||||
if (this.isNegative()) {
|
||||
return t.negate();
|
||||
}
|
||||
return t;
|
||||
};
|
||||
|
||||
NativeBigInt.prototype.modInv = SmallInteger.prototype.modInv = BigInteger.prototype.modInv;
|
||||
|
||||
BigInteger.prototype.next = function () {
|
||||
var value = this.value;
|
||||
if (this.sign) {
|
||||
return subtractSmall(value, 1, this.sign);
|
||||
}
|
||||
return new BigInteger(addSmall(value, 1), this.sign);
|
||||
};
|
||||
SmallInteger.prototype.next = function () {
|
||||
var value = this.value;
|
||||
if (value + 1 < MAX_INT) return new SmallInteger(value + 1);
|
||||
return new BigInteger(MAX_INT_ARR, false);
|
||||
};
|
||||
NativeBigInt.prototype.next = function () {
|
||||
return new NativeBigInt(this.value + BigInt(1));
|
||||
}
|
||||
|
||||
BigInteger.prototype.prev = function () {
|
||||
var value = this.value;
|
||||
if (this.sign) {
|
||||
return new BigInteger(addSmall(value, 1), true);
|
||||
}
|
||||
return subtractSmall(value, 1, this.sign);
|
||||
};
|
||||
SmallInteger.prototype.prev = function () {
|
||||
var value = this.value;
|
||||
if (value - 1 > -MAX_INT) return new SmallInteger(value - 1);
|
||||
return new BigInteger(MAX_INT_ARR, true);
|
||||
};
|
||||
NativeBigInt.prototype.prev = function () {
|
||||
return new NativeBigInt(this.value - BigInt(1));
|
||||
}
|
||||
|
||||
var powersOfTwo = [1];
|
||||
while (2 * powersOfTwo[powersOfTwo.length - 1] <= BASE) powersOfTwo.push(2 * powersOfTwo[powersOfTwo.length - 1]);
|
||||
var powers2Length = powersOfTwo.length, highestPower2 = powersOfTwo[powers2Length - 1];
|
||||
|
||||
function shift_isSmall(n) {
|
||||
return Math.abs(n) <= BASE;
|
||||
}
|
||||
|
||||
BigInteger.prototype.shiftLeft = function (v) {
|
||||
var n = parseValue(v).toJSNumber();
|
||||
if (!shift_isSmall(n)) {
|
||||
throw new Error(String(n) + " is too large for shifting.");
|
||||
}
|
||||
if (n < 0) return this.shiftRight(-n);
|
||||
var result = this;
|
||||
if (result.isZero()) return result;
|
||||
while (n >= powers2Length) {
|
||||
result = result.multiply(highestPower2);
|
||||
n -= powers2Length - 1;
|
||||
}
|
||||
return result.multiply(powersOfTwo[n]);
|
||||
};
|
||||
NativeBigInt.prototype.shiftLeft = SmallInteger.prototype.shiftLeft = BigInteger.prototype.shiftLeft;
|
||||
|
||||
BigInteger.prototype.shiftRight = function (v) {
|
||||
var remQuo;
|
||||
var n = parseValue(v).toJSNumber();
|
||||
if (!shift_isSmall(n)) {
|
||||
throw new Error(String(n) + " is too large for shifting.");
|
||||
}
|
||||
if (n < 0) return this.shiftLeft(-n);
|
||||
var result = this;
|
||||
while (n >= powers2Length) {
|
||||
if (result.isZero() || (result.isNegative() && result.isUnit())) return result;
|
||||
remQuo = divModAny(result, highestPower2);
|
||||
result = remQuo[1].isNegative() ? remQuo[0].prev() : remQuo[0];
|
||||
n -= powers2Length - 1;
|
||||
}
|
||||
remQuo = divModAny(result, powersOfTwo[n]);
|
||||
return remQuo[1].isNegative() ? remQuo[0].prev() : remQuo[0];
|
||||
};
|
||||
NativeBigInt.prototype.shiftRight = SmallInteger.prototype.shiftRight = BigInteger.prototype.shiftRight;
|
||||
|
||||
function bitwise(x, y, fn) {
|
||||
y = parseValue(y);
|
||||
var xSign = x.isNegative(), ySign = y.isNegative();
|
||||
var xRem = xSign ? x.not() : x,
|
||||
yRem = ySign ? y.not() : y;
|
||||
var xDigit = 0, yDigit = 0;
|
||||
var xDivMod = null, yDivMod = null;
|
||||
var result = [];
|
||||
while (!xRem.isZero() || !yRem.isZero()) {
|
||||
xDivMod = divModAny(xRem, highestPower2);
|
||||
xDigit = xDivMod[1].toJSNumber();
|
||||
if (xSign) {
|
||||
xDigit = highestPower2 - 1 - xDigit; // two's complement for negative numbers
|
||||
}
|
||||
|
||||
yDivMod = divModAny(yRem, highestPower2);
|
||||
yDigit = yDivMod[1].toJSNumber();
|
||||
if (ySign) {
|
||||
yDigit = highestPower2 - 1 - yDigit; // two's complement for negative numbers
|
||||
}
|
||||
|
||||
xRem = xDivMod[0];
|
||||
yRem = yDivMod[0];
|
||||
result.push(fn(xDigit, yDigit));
|
||||
}
|
||||
var sum = fn(xSign ? 1 : 0, ySign ? 1 : 0) !== 0 ? bigInt(-1) : bigInt(0);
|
||||
for (var i = result.length - 1; i >= 0; i -= 1) {
|
||||
sum = sum.multiply(highestPower2).add(bigInt(result[i]));
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
BigInteger.prototype.not = function () {
|
||||
return this.negate().prev();
|
||||
};
|
||||
NativeBigInt.prototype.not = SmallInteger.prototype.not = BigInteger.prototype.not;
|
||||
|
||||
BigInteger.prototype.and = function (n) {
|
||||
return bitwise(this, n, function (a, b) { return a & b; });
|
||||
};
|
||||
NativeBigInt.prototype.and = SmallInteger.prototype.and = BigInteger.prototype.and;
|
||||
|
||||
BigInteger.prototype.or = function (n) {
|
||||
return bitwise(this, n, function (a, b) { return a | b; });
|
||||
};
|
||||
NativeBigInt.prototype.or = SmallInteger.prototype.or = BigInteger.prototype.or;
|
||||
|
||||
BigInteger.prototype.xor = function (n) {
|
||||
return bitwise(this, n, function (a, b) { return a ^ b; });
|
||||
};
|
||||
NativeBigInt.prototype.xor = SmallInteger.prototype.xor = BigInteger.prototype.xor;
|
||||
|
||||
var LOBMASK_I = 1 << 30, LOBMASK_BI = (BASE & -BASE) * (BASE & -BASE) | LOBMASK_I;
|
||||
function roughLOB(n) { // get lowestOneBit (rough)
|
||||
// SmallInteger: return Min(lowestOneBit(n), 1 << 30)
|
||||
// BigInteger: return Min(lowestOneBit(n), 1 << 14) [BASE=1e7]
|
||||
var v = n.value,
|
||||
x = typeof v === "number" ? v | LOBMASK_I :
|
||||
typeof v === "bigint" ? v | BigInt(LOBMASK_I) :
|
||||
v[0] + v[1] * BASE | LOBMASK_BI;
|
||||
return x & -x;
|
||||
}
|
||||
|
||||
function integerLogarithm(value, base) {
|
||||
if (base.compareTo(value) <= 0) {
|
||||
var tmp = integerLogarithm(value, base.square(base));
|
||||
var p = tmp.p;
|
||||
var e = tmp.e;
|
||||
var t = p.multiply(base);
|
||||
return t.compareTo(value) <= 0 ? { p: t, e: e * 2 + 1 } : { p: p, e: e * 2 };
|
||||
}
|
||||
return { p: bigInt(1), e: 0 };
|
||||
}
|
||||
|
||||
BigInteger.prototype.bitLength = function () {
|
||||
var n = this;
|
||||
if (n.compareTo(bigInt(0)) < 0) {
|
||||
n = n.negate().subtract(bigInt(1));
|
||||
}
|
||||
if (n.compareTo(bigInt(0)) === 0) {
|
||||
return bigInt(0);
|
||||
}
|
||||
return bigInt(integerLogarithm(n, bigInt(2)).e).add(bigInt(1));
|
||||
}
|
||||
NativeBigInt.prototype.bitLength = SmallInteger.prototype.bitLength = BigInteger.prototype.bitLength;
|
||||
|
||||
function max(a, b) {
|
||||
a = parseValue(a);
|
||||
b = parseValue(b);
|
||||
return a.greater(b) ? a : b;
|
||||
}
|
||||
function min(a, b) {
|
||||
a = parseValue(a);
|
||||
b = parseValue(b);
|
||||
return a.lesser(b) ? a : b;
|
||||
}
|
||||
function gcd(a, b) {
|
||||
a = parseValue(a).abs();
|
||||
b = parseValue(b).abs();
|
||||
if (a.equals(b)) return a;
|
||||
if (a.isZero()) return b;
|
||||
if (b.isZero()) return a;
|
||||
var c = Integer[1], d, t;
|
||||
while (a.isEven() && b.isEven()) {
|
||||
d = min(roughLOB(a), roughLOB(b));
|
||||
a = a.divide(d);
|
||||
b = b.divide(d);
|
||||
c = c.multiply(d);
|
||||
}
|
||||
while (a.isEven()) {
|
||||
a = a.divide(roughLOB(a));
|
||||
}
|
||||
do {
|
||||
while (b.isEven()) {
|
||||
b = b.divide(roughLOB(b));
|
||||
}
|
||||
if (a.greater(b)) {
|
||||
t = b; b = a; a = t;
|
||||
}
|
||||
b = b.subtract(a);
|
||||
} while (!b.isZero());
|
||||
return c.isUnit() ? a : a.multiply(c);
|
||||
}
|
||||
function lcm(a, b) {
|
||||
a = parseValue(a).abs();
|
||||
b = parseValue(b).abs();
|
||||
return a.divide(gcd(a, b)).multiply(b);
|
||||
}
|
||||
function randBetween(a, b, rng) {
|
||||
a = parseValue(a);
|
||||
b = parseValue(b);
|
||||
var usedRNG = rng || Math.random;
|
||||
var low = min(a, b), high = max(a, b);
|
||||
var range = high.subtract(low).add(1);
|
||||
if (range.isSmall) return low.add(Math.floor(usedRNG() * range));
|
||||
var digits = toBase(range, BASE).value;
|
||||
var result = [], restricted = true;
|
||||
for (var i = 0; i < digits.length; i++) {
|
||||
var top = restricted ? digits[i] + (i + 1 < digits.length ? digits[i + 1] / BASE : 0) : BASE;
|
||||
var digit = truncate(usedRNG() * top);
|
||||
result.push(digit);
|
||||
if (digit < digits[i]) restricted = false;
|
||||
}
|
||||
return low.add(Integer.fromArray(result, BASE, false));
|
||||
}
|
||||
|
||||
var parseBase = function (text, base, alphabet, caseSensitive) {
|
||||
alphabet = alphabet || DEFAULT_ALPHABET;
|
||||
text = String(text);
|
||||
if (!caseSensitive) {
|
||||
text = text.toLowerCase();
|
||||
alphabet = alphabet.toLowerCase();
|
||||
}
|
||||
var length = text.length;
|
||||
var i;
|
||||
var absBase = Math.abs(base);
|
||||
var alphabetValues = {};
|
||||
for (i = 0; i < alphabet.length; i++) {
|
||||
alphabetValues[alphabet[i]] = i;
|
||||
}
|
||||
for (i = 0; i < length; i++) {
|
||||
var c = text[i];
|
||||
if (c === "-") continue;
|
||||
if (c in alphabetValues) {
|
||||
if (alphabetValues[c] >= absBase) {
|
||||
if (c === "1" && absBase === 1) continue;
|
||||
throw new Error(c + " is not a valid digit in base " + base + ".");
|
||||
}
|
||||
}
|
||||
}
|
||||
base = parseValue(base);
|
||||
var digits = [];
|
||||
var isNegative = text[0] === "-";
|
||||
for (i = isNegative ? 1 : 0; i < text.length; i++) {
|
||||
var c = text[i];
|
||||
if (c in alphabetValues) digits.push(parseValue(alphabetValues[c]));
|
||||
else if (c === "<") {
|
||||
var start = i;
|
||||
do { i++; } while (text[i] !== ">" && i < text.length);
|
||||
digits.push(parseValue(text.slice(start + 1, i)));
|
||||
}
|
||||
else throw new Error(c + " is not a valid character");
|
||||
}
|
||||
return parseBaseFromArray(digits, base, isNegative);
|
||||
};
|
||||
|
||||
function parseBaseFromArray(digits, base, isNegative) {
|
||||
var val = Integer[0], pow = Integer[1], i;
|
||||
for (i = digits.length - 1; i >= 0; i--) {
|
||||
val = val.add(digits[i].times(pow));
|
||||
pow = pow.times(base);
|
||||
}
|
||||
return isNegative ? val.negate() : val;
|
||||
}
|
||||
|
||||
function stringify(digit, alphabet) {
|
||||
alphabet = alphabet || DEFAULT_ALPHABET;
|
||||
if (digit < alphabet.length) {
|
||||
return alphabet[digit];
|
||||
}
|
||||
return "<" + digit + ">";
|
||||
}
|
||||
|
||||
function toBase(n, base) {
|
||||
base = bigInt(base);
|
||||
if (base.isZero()) {
|
||||
if (n.isZero()) return { value: [0], isNegative: false };
|
||||
throw new Error("Cannot convert nonzero numbers to base 0.");
|
||||
}
|
||||
if (base.equals(-1)) {
|
||||
if (n.isZero()) return { value: [0], isNegative: false };
|
||||
if (n.isNegative())
|
||||
return {
|
||||
value: [].concat.apply([], Array.apply(null, Array(-n.toJSNumber()))
|
||||
.map(Array.prototype.valueOf, [1, 0])
|
||||
),
|
||||
isNegative: false
|
||||
};
|
||||
|
||||
var arr = Array.apply(null, Array(n.toJSNumber() - 1))
|
||||
.map(Array.prototype.valueOf, [0, 1]);
|
||||
arr.unshift([1]);
|
||||
return {
|
||||
value: [].concat.apply([], arr),
|
||||
isNegative: false
|
||||
};
|
||||
}
|
||||
|
||||
var neg = false;
|
||||
if (n.isNegative() && base.isPositive()) {
|
||||
neg = true;
|
||||
n = n.abs();
|
||||
}
|
||||
if (base.isUnit()) {
|
||||
if (n.isZero()) return { value: [0], isNegative: false };
|
||||
|
||||
return {
|
||||
value: Array.apply(null, Array(n.toJSNumber()))
|
||||
.map(Number.prototype.valueOf, 1),
|
||||
isNegative: neg
|
||||
};
|
||||
}
|
||||
var out = [];
|
||||
var left = n, divmod;
|
||||
while (left.isNegative() || left.compareAbs(base) >= 0) {
|
||||
divmod = left.divmod(base);
|
||||
left = divmod.quotient;
|
||||
var digit = divmod.remainder;
|
||||
if (digit.isNegative()) {
|
||||
digit = base.minus(digit).abs();
|
||||
left = left.next();
|
||||
}
|
||||
out.push(digit.toJSNumber());
|
||||
}
|
||||
out.push(left.toJSNumber());
|
||||
return { value: out.reverse(), isNegative: neg };
|
||||
}
|
||||
|
||||
function toBaseString(n, base, alphabet) {
|
||||
var arr = toBase(n, base);
|
||||
return (arr.isNegative ? "-" : "") + arr.value.map(function (x) {
|
||||
return stringify(x, alphabet);
|
||||
}).join('');
|
||||
}
|
||||
|
||||
BigInteger.prototype.toArray = function (radix) {
|
||||
return toBase(this, radix);
|
||||
};
|
||||
|
||||
SmallInteger.prototype.toArray = function (radix) {
|
||||
return toBase(this, radix);
|
||||
};
|
||||
|
||||
NativeBigInt.prototype.toArray = function (radix) {
|
||||
return toBase(this, radix);
|
||||
};
|
||||
|
||||
BigInteger.prototype.toString = function (radix, alphabet) {
|
||||
if (radix === undefined) radix = 10;
|
||||
if (radix !== 10 || alphabet) return toBaseString(this, radix, alphabet);
|
||||
var v = this.value, l = v.length, str = String(v[--l]), zeros = "0000000", digit;
|
||||
while (--l >= 0) {
|
||||
digit = String(v[l]);
|
||||
str += zeros.slice(digit.length) + digit;
|
||||
}
|
||||
var sign = this.sign ? "-" : "";
|
||||
return sign + str;
|
||||
};
|
||||
|
||||
SmallInteger.prototype.toString = function (radix, alphabet) {
|
||||
if (radix === undefined) radix = 10;
|
||||
if (radix != 10 || alphabet) return toBaseString(this, radix, alphabet);
|
||||
return String(this.value);
|
||||
};
|
||||
|
||||
NativeBigInt.prototype.toString = SmallInteger.prototype.toString;
|
||||
|
||||
NativeBigInt.prototype.toJSON = BigInteger.prototype.toJSON = SmallInteger.prototype.toJSON = function () { return this.toString(); }
|
||||
|
||||
BigInteger.prototype.valueOf = function () {
|
||||
return parseInt(this.toString(), 10);
|
||||
};
|
||||
BigInteger.prototype.toJSNumber = BigInteger.prototype.valueOf;
|
||||
|
||||
SmallInteger.prototype.valueOf = function () {
|
||||
return this.value;
|
||||
};
|
||||
SmallInteger.prototype.toJSNumber = SmallInteger.prototype.valueOf;
|
||||
NativeBigInt.prototype.valueOf = NativeBigInt.prototype.toJSNumber = function () {
|
||||
return parseInt(this.toString(), 10);
|
||||
}
|
||||
|
||||
function parseStringValue(v) {
|
||||
if (isPrecise(+v)) {
|
||||
var x = +v;
|
||||
if (x === truncate(x))
|
||||
return supportsNativeBigInt ? new NativeBigInt(BigInt(x)) : new SmallInteger(x);
|
||||
throw new Error("Invalid integer: " + v);
|
||||
}
|
||||
var sign = v[0] === "-";
|
||||
if (sign) v = v.slice(1);
|
||||
var split = v.split(/e/i);
|
||||
if (split.length > 2) throw new Error("Invalid integer: " + split.join("e"));
|
||||
if (split.length === 2) {
|
||||
var exp = split[1];
|
||||
if (exp[0] === "+") exp = exp.slice(1);
|
||||
exp = +exp;
|
||||
if (exp !== truncate(exp) || !isPrecise(exp)) throw new Error("Invalid integer: " + exp + " is not a valid exponent.");
|
||||
var text = split[0];
|
||||
var decimalPlace = text.indexOf(".");
|
||||
if (decimalPlace >= 0) {
|
||||
exp -= text.length - decimalPlace - 1;
|
||||
text = text.slice(0, decimalPlace) + text.slice(decimalPlace + 1);
|
||||
}
|
||||
if (exp < 0) throw new Error("Cannot include negative exponent part for integers");
|
||||
text += (new Array(exp + 1)).join("0");
|
||||
v = text;
|
||||
}
|
||||
var isValid = /^([0-9][0-9]*)$/.test(v);
|
||||
if (!isValid) throw new Error("Invalid integer: " + v);
|
||||
if (supportsNativeBigInt) {
|
||||
return new NativeBigInt(BigInt(sign ? "-" + v : v));
|
||||
}
|
||||
var r = [], max = v.length, l = LOG_BASE, min = max - l;
|
||||
while (max > 0) {
|
||||
r.push(+v.slice(min, max));
|
||||
min -= l;
|
||||
if (min < 0) min = 0;
|
||||
max -= l;
|
||||
}
|
||||
trim(r);
|
||||
return new BigInteger(r, sign);
|
||||
}
|
||||
|
||||
function parseNumberValue(v) {
|
||||
if (supportsNativeBigInt) {
|
||||
return new NativeBigInt(BigInt(v));
|
||||
}
|
||||
if (isPrecise(v)) {
|
||||
if (v !== truncate(v)) throw new Error(v + " is not an integer.");
|
||||
return new SmallInteger(v);
|
||||
}
|
||||
return parseStringValue(v.toString());
|
||||
}
|
||||
|
||||
function parseValue(v) {
|
||||
if (typeof v === "number") {
|
||||
return parseNumberValue(v);
|
||||
}
|
||||
if (typeof v === "string") {
|
||||
return parseStringValue(v);
|
||||
}
|
||||
if (typeof v === "bigint") {
|
||||
return new NativeBigInt(v);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
// Pre-define numbers in range [-999,999]
|
||||
for (var i = 0; i < 1000; i++) {
|
||||
Integer[i] = parseValue(i);
|
||||
if (i > 0) Integer[-i] = parseValue(-i);
|
||||
}
|
||||
// Backwards compatibility
|
||||
Integer.one = Integer[1];
|
||||
Integer.zero = Integer[0];
|
||||
Integer.minusOne = Integer[-1];
|
||||
Integer.max = max;
|
||||
Integer.min = min;
|
||||
Integer.gcd = gcd;
|
||||
Integer.lcm = lcm;
|
||||
Integer.isInstance = function (x) { return x instanceof BigInteger || x instanceof SmallInteger || x instanceof NativeBigInt; };
|
||||
Integer.randBetween = randBetween;
|
||||
|
||||
Integer.fromArray = function (digits, base, isNegative) {
|
||||
return parseBaseFromArray(digits.map(parseValue), parseValue(base || 10), isNegative);
|
||||
};
|
||||
|
||||
return Integer;
|
||||
})();
|
||||
|
||||
// Node.js check
|
||||
if (typeof module !== "undefined" && module.hasOwnProperty("exports")) {
|
||||
module.exports = bigInt;
|
||||
}
|
||||
|
||||
//amd check
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define( function () {
|
||||
return bigInt;
|
||||
});
|
||||
}
|
||||
+1
File diff suppressed because one or more lines are too long
+24
@@ -0,0 +1,24 @@
|
||||
This is free and unencumbered software released into the public domain.
|
||||
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||
distribute this software, either in source code form or as a compiled
|
||||
binary, for any purpose, commercial or non-commercial, and by any
|
||||
means.
|
||||
|
||||
In jurisdictions that recognize copyright laws, the author or authors
|
||||
of this software dedicate any and all copyright interest in the
|
||||
software to the public domain. We make this dedication for the benefit
|
||||
of the public at large and to the detriment of our heirs and
|
||||
successors. We intend this dedication to be an overt act of
|
||||
relinquishment in perpetuity of all present and future rights to this
|
||||
software under copyright law.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
For more information, please refer to <http://unlicense.org>
|
||||
+589
@@ -0,0 +1,589 @@
|
||||
# BigInteger.js [![Build Status][travis-img]][travis-url] [![Coverage Status][coveralls-img]][coveralls-url] [![Monthly Downloads][downloads-img]][downloads-url]
|
||||
|
||||
[travis-url]: https://travis-ci.org/peterolson/BigInteger.js
|
||||
[travis-img]: https://travis-ci.org/peterolson/BigInteger.js.svg?branch=master
|
||||
[coveralls-url]: https://coveralls.io/github/peterolson/BigInteger.js?branch=master
|
||||
[coveralls-img]: https://coveralls.io/repos/peterolson/BigInteger.js/badge.svg?branch=master&service=github
|
||||
[downloads-url]: https://www.npmjs.com/package/big-integer
|
||||
[downloads-img]: https://img.shields.io/npm/dm/big-integer.svg
|
||||
|
||||
**BigInteger.js** is an arbitrary-length integer library for Javascript, allowing arithmetic operations on integers of unlimited size, notwithstanding memory and time limitations.
|
||||
|
||||
**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.
|
||||
|
||||
## Installation
|
||||
|
||||
If you are using a browser, you can download [BigInteger.js from GitHub](http://peterolson.github.com/BigInteger.js/BigInteger.min.js) or just hotlink to it:
|
||||
|
||||
<script src="https://peterolson.github.io/BigInteger.js/BigInteger.min.js"></script>
|
||||
|
||||
If you are using node, you can install BigInteger with [npm](https://npmjs.org/).
|
||||
|
||||
npm install big-integer
|
||||
|
||||
Then you can include it in your code:
|
||||
|
||||
var bigInt = require("big-integer");
|
||||
|
||||
|
||||
## Usage
|
||||
### `bigInt(number, [base], [alphabet], [caseSensitive])`
|
||||
|
||||
You can create a bigInt by calling the `bigInt` function. You can pass in
|
||||
|
||||
- a string, which it will parse as an bigInt and throw an `"Invalid integer"` error if the parsing fails.
|
||||
- a Javascript number, which it will parse as an bigInt and throw an `"Invalid integer"` error if the parsing fails.
|
||||
- another bigInt.
|
||||
- nothing, and it will return `bigInt.zero`.
|
||||
|
||||
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`.
|
||||
|
||||
You can specify a custom alphabet for base conversion with the third parameter. The default `alphabet` is `"0123456789abcdefghijklmnopqrstuvwxyz"`.
|
||||
|
||||
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`.
|
||||
|
||||
Examples:
|
||||
|
||||
var zero = bigInt();
|
||||
var ninetyThree = bigInt(93);
|
||||
var largeNumber = bigInt("75643564363473453456342378564387956906736546456235345");
|
||||
var googol = bigInt("1e100");
|
||||
var bigNumber = bigInt(largeNumber);
|
||||
|
||||
var maximumByte = bigInt("FF", 16);
|
||||
var fiftyFiveGoogol = bigInt("<55>0", googol);
|
||||
|
||||
Note 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.
|
||||
|
||||
### Method Chaining
|
||||
|
||||
Note that bigInt operations return bigInts, which allows you to chain methods, for example:
|
||||
|
||||
var salary = bigInt(dollarsPerHour).times(hoursWorked).plus(randomBonuses)
|
||||
|
||||
### Constants
|
||||
|
||||
There are three named constants already stored that you do not have to construct with the `bigInt` function yourself:
|
||||
|
||||
- `bigInt.one`, equivalent to `bigInt(1)`
|
||||
- `bigInt.zero`, equivalent to `bigInt(0)`
|
||||
- `bigInt.minusOne`, equivalent to `bigInt(-1)`
|
||||
|
||||
The numbers from -999 to 999 are also already prestored and can be accessed using `bigInt[index]`, for example:
|
||||
|
||||
- `bigInt[-999]`, equivalent to `bigInt(-999)`
|
||||
- `bigInt[256]`, equivalent to `bigInt(256)`
|
||||
|
||||
### Methods
|
||||
|
||||
#### `abs()`
|
||||
|
||||
Returns the absolute value of a bigInt.
|
||||
|
||||
- `bigInt(-45).abs()` => `45`
|
||||
- `bigInt(45).abs()` => `45`
|
||||
|
||||
#### `add(number)`
|
||||
|
||||
Performs addition.
|
||||
|
||||
- `bigInt(5).add(7)` => `12`
|
||||
|
||||
[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Addition)
|
||||
|
||||
#### `and(number)`
|
||||
|
||||
Performs 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).
|
||||
|
||||
- `bigInt(6).and(3)` => `2`
|
||||
- `bigInt(6).and(-3)` => `4`
|
||||
|
||||
#### `bitLength()`
|
||||
|
||||
Returns the number of digits required to represent a bigInt in binary.
|
||||
|
||||
- `bigInt(5)` => `3` (since 5 is `101` in binary, which is three digits long)
|
||||
|
||||
#### `compare(number)`
|
||||
|
||||
Performs 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`.
|
||||
|
||||
- `bigInt(5).compare(5)` => `0`
|
||||
- `bigInt(5).compare(4)` => `1`
|
||||
- `bigInt(4).compare(5)` => `-1`
|
||||
|
||||
#### `compareAbs(number)`
|
||||
|
||||
Performs a comparison between the absolute value of two numbers.
|
||||
|
||||
- `bigInt(5).compareAbs(-5)` => `0`
|
||||
- `bigInt(5).compareAbs(4)` => `1`
|
||||
- `bigInt(4).compareAbs(-5)` => `-1`
|
||||
|
||||
#### `compareTo(number)`
|
||||
|
||||
Alias for the `compare` method.
|
||||
|
||||
#### `divide(number)`
|
||||
|
||||
Performs integer division, disregarding the remainder.
|
||||
|
||||
- `bigInt(59).divide(5)` => `11`
|
||||
|
||||
[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Division)
|
||||
|
||||
#### `divmod(number)`
|
||||
|
||||
Performs division and returns an object with two properties: `quotient` and `remainder`. The sign of the remainder will match the sign of the dividend.
|
||||
|
||||
- `bigInt(59).divmod(5)` => `{quotient: bigInt(11), remainder: bigInt(4) }`
|
||||
- `bigInt(-5).divmod(2)` => `{quotient: bigInt(-2), remainder: bigInt(-1) }`
|
||||
|
||||
[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Division)
|
||||
|
||||
#### `eq(number)`
|
||||
|
||||
Alias for the `equals` method.
|
||||
|
||||
#### `equals(number)`
|
||||
|
||||
Checks if two numbers are equal.
|
||||
|
||||
- `bigInt(5).equals(5)` => `true`
|
||||
- `bigInt(4).equals(7)` => `false`
|
||||
|
||||
#### `geq(number)`
|
||||
|
||||
Alias for the `greaterOrEquals` method.
|
||||
|
||||
|
||||
#### `greater(number)`
|
||||
|
||||
Checks if the first number is greater than the second.
|
||||
|
||||
- `bigInt(5).greater(6)` => `false`
|
||||
- `bigInt(5).greater(5)` => `false`
|
||||
- `bigInt(5).greater(4)` => `true`
|
||||
|
||||
#### `greaterOrEquals(number)`
|
||||
|
||||
Checks if the first number is greater than or equal to the second.
|
||||
|
||||
- `bigInt(5).greaterOrEquals(6)` => `false`
|
||||
- `bigInt(5).greaterOrEquals(5)` => `true`
|
||||
- `bigInt(5).greaterOrEquals(4)` => `true`
|
||||
|
||||
#### `gt(number)`
|
||||
|
||||
Alias for the `greater` method.
|
||||
|
||||
#### `isDivisibleBy(number)`
|
||||
|
||||
Returns `true` if the first number is divisible by the second number, `false` otherwise.
|
||||
|
||||
- `bigInt(999).isDivisibleBy(333)` => `true`
|
||||
- `bigInt(99).isDivisibleBy(5)` => `false`
|
||||
|
||||
#### `isEven()`
|
||||
|
||||
Returns `true` if the number is even, `false` otherwise.
|
||||
|
||||
- `bigInt(6).isEven()` => `true`
|
||||
- `bigInt(3).isEven()` => `false`
|
||||
|
||||
#### `isNegative()`
|
||||
|
||||
Returns `true` if the number is negative, `false` otherwise.
|
||||
Returns `false` for `0` and `-0`.
|
||||
|
||||
- `bigInt(-23).isNegative()` => `true`
|
||||
- `bigInt(50).isNegative()` => `false`
|
||||
|
||||
#### `isOdd()`
|
||||
|
||||
Returns `true` if the number is odd, `false` otherwise.
|
||||
|
||||
- `bigInt(13).isOdd()` => `true`
|
||||
- `bigInt(40).isOdd()` => `false`
|
||||
|
||||
#### `isPositive()`
|
||||
|
||||
Return `true` if the number is positive, `false` otherwise.
|
||||
Returns `false` for `0` and `-0`.
|
||||
|
||||
- `bigInt(54).isPositive()` => `true`
|
||||
- `bigInt(-1).isPositive()` => `false`
|
||||
|
||||
#### `isPrime(strict?)`
|
||||
|
||||
Returns `true` if the number is prime, `false` otherwise.
|
||||
Set "strict" boolean to true to force GRH-supported lower bound of 2*log(N)^2.
|
||||
|
||||
- `bigInt(5).isPrime()` => `true`
|
||||
- `bigInt(6).isPrime()` => `false`
|
||||
|
||||
#### `isProbablePrime([iterations], [rng])`
|
||||
|
||||
Returns `true` if the number is very likely to be prime, `false` otherwise.
|
||||
Supplying `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.
|
||||
This uses the [Miller Rabin test](https://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test).
|
||||
|
||||
- `bigInt(5).isProbablePrime()` => `true`
|
||||
- `bigInt(49).isProbablePrime()` => `false`
|
||||
- `bigInt(1729).isProbablePrime()` => `false`
|
||||
|
||||
Note 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`.
|
||||
|
||||
- `bigInt(1729).isProbablePrime(1, () => 0.1)` => `false`
|
||||
- `bigInt(1729).isProbablePrime(1, () => 0.2)` => `true`
|
||||
|
||||
If 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`.
|
||||
If the number is prime, this function always returns `true`.
|
||||
|
||||
#### `isUnit()`
|
||||
|
||||
Returns `true` if the number is `1` or `-1`, `false` otherwise.
|
||||
|
||||
- `bigInt.one.isUnit()` => `true`
|
||||
- `bigInt.minusOne.isUnit()` => `true`
|
||||
- `bigInt(5).isUnit()` => `false`
|
||||
|
||||
#### `isZero()`
|
||||
|
||||
Return `true` if the number is `0` or `-0`, `false` otherwise.
|
||||
|
||||
- `bigInt.zero.isZero()` => `true`
|
||||
- `bigInt("-0").isZero()` => `true`
|
||||
- `bigInt(50).isZero()` => `false`
|
||||
|
||||
#### `leq(number)`
|
||||
|
||||
Alias for the `lesserOrEquals` method.
|
||||
|
||||
#### `lesser(number)`
|
||||
|
||||
Checks if the first number is lesser than the second.
|
||||
|
||||
- `bigInt(5).lesser(6)` => `true`
|
||||
- `bigInt(5).lesser(5)` => `false`
|
||||
- `bigInt(5).lesser(4)` => `false`
|
||||
|
||||
#### `lesserOrEquals(number)`
|
||||
|
||||
Checks if the first number is less than or equal to the second.
|
||||
|
||||
- `bigInt(5).lesserOrEquals(6)` => `true`
|
||||
- `bigInt(5).lesserOrEquals(5)` => `true`
|
||||
- `bigInt(5).lesserOrEquals(4)` => `false`
|
||||
|
||||
#### `lt(number)`
|
||||
|
||||
Alias for the `lesser` method.
|
||||
|
||||
#### `minus(number)`
|
||||
|
||||
Alias for the `subtract` method.
|
||||
|
||||
- `bigInt(3).minus(5)` => `-2`
|
||||
|
||||
[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Subtraction)
|
||||
|
||||
#### `mod(number)`
|
||||
|
||||
Performs division and returns the remainder, disregarding the quotient. The sign of the remainder will match the sign of the dividend.
|
||||
|
||||
- `bigInt(59).mod(5)` => `4`
|
||||
- `bigInt(-5).mod(2)` => `-1`
|
||||
|
||||
[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Division)
|
||||
|
||||
#### `modInv(mod)`
|
||||
|
||||
Finds the [multiplicative inverse](https://en.wikipedia.org/wiki/Modular_multiplicative_inverse) of the number modulo `mod`.
|
||||
|
||||
- `bigInt(3).modInv(11)` => `4`
|
||||
- `bigInt(42).modInv(2017)` => `1969`
|
||||
|
||||
#### `modPow(exp, mod)`
|
||||
|
||||
Takes the number to the power `exp` modulo `mod`.
|
||||
|
||||
- `bigInt(10).modPow(3, 30)` => `10`
|
||||
|
||||
#### `multiply(number)`
|
||||
|
||||
Performs multiplication.
|
||||
|
||||
- `bigInt(111).multiply(111)` => `12321`
|
||||
|
||||
[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Multiplication)
|
||||
|
||||
#### `neq(number)`
|
||||
|
||||
Alias for the `notEquals` method.
|
||||
|
||||
#### `next()`
|
||||
|
||||
Adds one to the number.
|
||||
|
||||
- `bigInt(6).next()` => `7`
|
||||
|
||||
#### `not()`
|
||||
|
||||
Performs 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).
|
||||
|
||||
- `bigInt(10).not()` => `-11`
|
||||
- `bigInt(0).not()` => `-1`
|
||||
|
||||
#### `notEquals(number)`
|
||||
|
||||
Checks if two numbers are not equal.
|
||||
|
||||
- `bigInt(5).notEquals(5)` => `false`
|
||||
- `bigInt(4).notEquals(7)` => `true`
|
||||
|
||||
#### `or(number)`
|
||||
|
||||
Performs 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).
|
||||
|
||||
- `bigInt(13).or(10)` => `15`
|
||||
- `bigInt(13).or(-8)` => `-3`
|
||||
|
||||
#### `over(number)`
|
||||
|
||||
Alias for the `divide` method.
|
||||
|
||||
- `bigInt(59).over(5)` => `11`
|
||||
|
||||
[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Division)
|
||||
|
||||
#### `plus(number)`
|
||||
|
||||
Alias for the `add` method.
|
||||
|
||||
- `bigInt(5).plus(7)` => `12`
|
||||
|
||||
[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Addition)
|
||||
|
||||
#### `pow(number)`
|
||||
|
||||
Performs exponentiation. If the exponent is less than `0`, `pow` returns `0`. `bigInt.zero.pow(0)` returns `1`.
|
||||
|
||||
- `bigInt(16).pow(16)` => `18446744073709551616`
|
||||
|
||||
[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Exponentiation)
|
||||
|
||||
#### `prev(number)`
|
||||
|
||||
Subtracts one from the number.
|
||||
|
||||
- `bigInt(6).prev()` => `5`
|
||||
|
||||
#### `remainder(number)`
|
||||
|
||||
Alias for the `mod` method.
|
||||
|
||||
[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Division)
|
||||
|
||||
#### `shiftLeft(n)`
|
||||
|
||||
Shifts 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]`.
|
||||
|
||||
- `bigInt(8).shiftLeft(2)` => `32`
|
||||
- `bigInt(8).shiftLeft(-2)` => `2`
|
||||
|
||||
#### `shiftRight(n)`
|
||||
|
||||
Shifts 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]`.
|
||||
|
||||
- `bigInt(8).shiftRight(2)` => `2`
|
||||
- `bigInt(8).shiftRight(-2)` => `32`
|
||||
|
||||
#### `square()`
|
||||
|
||||
Squares the number
|
||||
|
||||
- `bigInt(3).square()` => `9`
|
||||
|
||||
[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Squaring)
|
||||
|
||||
#### `subtract(number)`
|
||||
|
||||
Performs subtraction.
|
||||
|
||||
- `bigInt(3).subtract(5)` => `-2`
|
||||
|
||||
[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Subtraction)
|
||||
|
||||
#### `times(number)`
|
||||
|
||||
Alias for the `multiply` method.
|
||||
|
||||
- `bigInt(111).times(111)` => `12321`
|
||||
|
||||
[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#Multiplication)
|
||||
|
||||
#### `toArray(radix)`
|
||||
|
||||
Converts 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.
|
||||
|
||||
- `bigInt("1e9").toArray(10)` => {
|
||||
value: [1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
isNegative: false
|
||||
}
|
||||
- `bigInt("1e9").toArray(16)` => {
|
||||
value: [3, 11, 9, 10, 12, 10, 0, 0],
|
||||
isNegative: false
|
||||
}
|
||||
- `bigInt(567890).toArray(100)` => {
|
||||
value: [56, 78, 90],
|
||||
isNegative: false
|
||||
}
|
||||
|
||||
Negative bases are supported.
|
||||
|
||||
- `bigInt(12345).toArray(-10)` => {
|
||||
value: [2, 8, 4, 6, 5],
|
||||
isNegative: false
|
||||
}
|
||||
|
||||
Base 1 and base -1 are also supported.
|
||||
|
||||
- `bigInt(-15).toArray(1)` => {
|
||||
value: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
|
||||
isNegative: true
|
||||
}
|
||||
- `bigInt(-15).toArray(-1)` => {
|
||||
value: [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
|
||||
0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],
|
||||
isNegative: false
|
||||
}
|
||||
|
||||
Base 0 is only allowed for the number zero.
|
||||
|
||||
- `bigInt(0).toArray(0)` => {
|
||||
value: [0],
|
||||
isNegative: false
|
||||
}
|
||||
- `bigInt(1).toArray(0)` => `Error: Cannot convert nonzero numbers to base 0.`
|
||||
|
||||
#### `toJSNumber()`
|
||||
|
||||
Converts a bigInt into a native Javascript number. Loses precision for numbers outside the range `[-9007199254740992, 9007199254740992]`.
|
||||
|
||||
- `bigInt("18446744073709551616").toJSNumber()` => `18446744073709552000`
|
||||
|
||||
#### `xor(number)`
|
||||
|
||||
Performs 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).
|
||||
|
||||
- `bigInt(12).xor(5)` => `9`
|
||||
- `bigInt(12).xor(-5)` => `-9`
|
||||
|
||||
### Static Methods
|
||||
|
||||
#### `fromArray(digits, base = 10, isNegative?)`
|
||||
|
||||
Constructs a bigInt from an array of digits in base `base`. The optional `isNegative` flag will make the number negative.
|
||||
|
||||
- `bigInt.fromArray([1, 2, 3, 4, 5], 10)` => `12345`
|
||||
- `bigInt.fromArray([1, 0, 0], 2, true)` => `-4`
|
||||
|
||||
#### `gcd(a, b)`
|
||||
|
||||
Finds the greatest common denominator of `a` and `b`.
|
||||
|
||||
- `bigInt.gcd(42,56)` => `14`
|
||||
|
||||
#### `isInstance(x)`
|
||||
|
||||
Returns `true` if `x` is a BigInteger, `false` otherwise.
|
||||
|
||||
- `bigInt.isInstance(bigInt(14))` => `true`
|
||||
- `bigInt.isInstance(14)` => `false`
|
||||
|
||||
#### `lcm(a,b)`
|
||||
|
||||
Finds the least common multiple of `a` and `b`.
|
||||
|
||||
- `bigInt.lcm(21, 6)` => `42`
|
||||
|
||||
#### `max(a,b)`
|
||||
|
||||
Returns the largest of `a` and `b`.
|
||||
|
||||
- `bigInt.max(77, 432)` => `432`
|
||||
|
||||
#### `min(a,b)`
|
||||
|
||||
Returns the smallest of `a` and `b`.
|
||||
|
||||
- `bigInt.min(77, 432)` => `77`
|
||||
|
||||
#### `randBetween(min, max, [rng])`
|
||||
|
||||
Returns a random number between `min` and `max`, optionally using `rng` to generate randomness.
|
||||
|
||||
- `bigInt.randBetween("-1e100", "1e100")` => (for example) `8494907165436643479673097939554427056789510374838494147955756275846226209006506706784609314471378745`
|
||||
|
||||
`rng` should take no arguments and return a `number` between 0 and 1. It defaults to `Math.random`.
|
||||
|
||||
- `bigInt.randBetween("-1e100", "1e100", () => 0.5)` => (always) `50000005000000500000050000005000000500000050000005000000500000050000005000000500000050000005000000`
|
||||
|
||||
|
||||
### Override Methods
|
||||
|
||||
#### `toString(radix = 10, [alphabet])`
|
||||
|
||||
Converts 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`.
|
||||
|
||||
- `bigInt("1e9").toString()` => `"1000000000"`
|
||||
- `bigInt("1e9").toString(16)` => `"3b9aca00"`
|
||||
|
||||
You can use a custom base alphabet with the second parameter. The default `alphabet` is `"0123456789abcdefghijklmnopqrstuvwxyz"`.
|
||||
|
||||
- `bigInt("5").toString(2, "aA")` => `"AaA"`
|
||||
|
||||
**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.
|
||||
|
||||
- `bigInt("999999999999999999").toString()` => `"999999999999999999"`
|
||||
- `String(bigInt("999999999999999999"))` => `"999999999999999999"`
|
||||
- `bigInt("999999999999999999") + ""` => `1000000000000000000`
|
||||
|
||||
Bases larger than 36 are supported. If a digit is greater than or equal to 36, it will be enclosed in angle brackets.
|
||||
|
||||
- `bigInt(567890).toString(100)` => `"<56><78><90>"`
|
||||
|
||||
Negative bases are also supported.
|
||||
|
||||
- `bigInt(12345).toString(-10)` => `"28465"`
|
||||
|
||||
Base 1 and base -1 are also supported.
|
||||
|
||||
- `bigInt(-15).toString(1)` => `"-111111111111111"`
|
||||
- `bigInt(-15).toString(-1)` => `"101010101010101010101010101010"`
|
||||
|
||||
Base 0 is only allowed for the number zero.
|
||||
|
||||
- `bigInt(0).toString(0)` => `0`
|
||||
- `bigInt(1).toString(0)` => `Error: Cannot convert nonzero numbers to base 0.`
|
||||
|
||||
[View benchmarks for this method](http://peterolson.github.io/BigInteger.js/benchmark/#toString)
|
||||
|
||||
#### `valueOf()`
|
||||
|
||||
Converts a bigInt to a native Javascript number. This override allows you to use native arithmetic operators without explicit conversion:
|
||||
|
||||
- `bigInt("100") + bigInt("200") === 300; //true`
|
||||
|
||||
## Contributors
|
||||
|
||||
To contribute, just fork the project, make some changes, and submit a pull request. Please verify that the unit tests pass before submitting.
|
||||
|
||||
The 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://peterolson.github.io/BigInteger.js/spec/SpecRunner.html).
|
||||
|
||||
There are performance benchmarks that can be viewed from the `benchmarks/index.html` page. You can [run them online from GitHub](http://peterolson.github.io/BigInteger.js/benchmark/).
|
||||
|
||||
## License
|
||||
|
||||
This project is public domain. For more details, read about the [Unlicense](http://unlicense.org/).
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "big-integer",
|
||||
"description": "An arbitrary length integer library for Javascript",
|
||||
"main": "./BigInteger.js",
|
||||
"authors": [
|
||||
"Peter Olson"
|
||||
],
|
||||
"license": "Unlicense",
|
||||
"keywords": [
|
||||
"math",
|
||||
"big",
|
||||
"bignum",
|
||||
"bigint",
|
||||
"biginteger",
|
||||
"integer",
|
||||
"arbitrary",
|
||||
"precision",
|
||||
"arithmetic"
|
||||
],
|
||||
"homepage": "https://github.com/peterolson/BigInteger.js",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"coverage",
|
||||
"tests"
|
||||
]
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"name": "big-integer",
|
||||
"version": "1.6.52",
|
||||
"author": "Peter Olson <peter.e.c.olson+npm@gmail.com>",
|
||||
"description": "An arbitrary length integer library for Javascript",
|
||||
"contributors": [],
|
||||
"bin": {},
|
||||
"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@github.com:peterolson/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"
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "esnext",
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "./",
|
||||
"moduleResolution": "node",
|
||||
"allowJs": true,
|
||||
"typeRoots": [
|
||||
"./"
|
||||
],
|
||||
"types": [],
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"BigInteger.d.ts",
|
||||
"spec/tsDefinitions.ts"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user