Static variables

@:value(new BigInt(BigInt_.fromInt(-1)))staticread onlyMINUS_ONE:BigInt = new BigInt(BigInt_.fromInt(-1))

The BigInt value of -1

@:value(new BigInt(BigInt_.fromInt(1)))staticread onlyONE:BigInt = new BigInt(BigInt_.fromInt(1))

The BigInt value of 1

@:value(new BigInt(BigInt_.fromInt(2)))staticread onlyTWO:BigInt = new BigInt(BigInt_.fromInt(2))

The BigInt value of 2

@:value(new BigInt(BigInt_.fromInt(0)))staticread onlyZERO:BigInt = new BigInt(BigInt_.fromInt(0))

The BigInt value of 0

Static methods

staticabs(this:BigInt_):BigInt

Returns the absolute value of this BigInt.

Returns:

A new BigInt representing the absolute value.

staticbitCount(this:BigInt_):Int

Counts the number of bits that are set to 1.

Returns:

The number of set bits.

staticbitLength(this:BigInt_):Int

Returns the number of bits of this BigInt.

Returns:

The number of bits required to represent this number.

staticclearBit(this:BigInt_, n:Int):BigInt

Returns a new BigInt with the specified bit cleared (to 0).

Parameters:

n

The index of the bit to clear.

Returns:

A new BigInt with the bit cleared.

staticdivMod(dividend:BigInt, divisor:BigInt):{remainder:BigInt, quotient:BigInt}

Performs division and returns both the quotient and the remainder.

Parameters:

dividend

The number to be divided.

divisor

The number to divide by.

Returns:

An object { quotient: BigInt, remainder: BigInt }.

staticflipBit(this:BigInt_, n:Int):BigInt

Returns a new BigInt with the specified bit flipped.

Parameters:

n

The index of the bit to flip.

Returns:

A new BigInt with the bit flipped.

@:value({ length : 0, offset : 0 })staticinlinefromBytes(value:Bytes, offset:Int = 0, length:Int = 0):BigInt

Creates a BigInt from a Bytes sequence.

Parameters:

value

The Bytes object to read from.

offset

The starting position in the bytes.

length

The number of bytes to read. If 0, reads to the end.

Returns:

A new BigInt instance.

staticinlinefromHex(value:String):BigInt

Creates a BigInt from a hexadecimal string. Assumes signed representation. This is a shorthand for fromHexSigned(value).

Parameters:

value

The hexadecimal string.

Returns:

A new BigInt instance.

staticinlinefromHexSigned(value:String):BigInt

Creates a BigInt from a signed hexadecimal string.

Parameters:

value

The hexadecimal string.

Returns:

A new BigInt instance.

staticinlinefromHexUnsigned(value:String):BigInt

Creates a BigInt from an unsigned hexadecimal string.

Parameters:

value

The hexadecimal string.

Returns:

A new BigInt instance.

staticinlinefromInt(value:Int):BigInt

Creates a new BigInt from an Int.

Parameters:

value

The Int value.

@:value({ radix : 10 })staticinlinefromString(value:String, radix:Int = 10):BigInt

Creates a BigInt by parsing a string with a given radix.

Parameters:

value

The string representation of the number.

radix

The base of the number in the string (e.g., 10 or 16).

Returns:

A new BigInt instance.

@:value({ length : 0 })staticinlinefromUnsignedInts(value:Vector<Int>, length:Int = 0):BigInt

Creates a BigInt from a Vector of unsigned Int words.

Parameters:

value

A vector containing the integer words of the number.

length

The number of words to use from the vector. If 0, uses the whole vector.

Returns:

A new BigInt instance.

staticgcd(this:BigInt_, b:BigInt):BigInt

Finds the greatest common divisor (GCD) of this BigInt and another.

Parameters:

b

The other BigInt.

Returns:

The GCD of this and b.

staticinlinegetBit(this:BigInt_, index:Int):Int

Gets the value of a single bit at the specified index.

Parameters:

index

The zero-based index of the bit to get.

Returns:

1 if the bit is set, otherwise 0.

staticgetLowestSetBit(this:BigInt_):Int

Gets the index of the lowest-set (rightmost) bit.

Returns:

The index of the rightmost '1' bit, or -1 if the number is zero.

staticgetPowerOfTwo(exponent:Int):BigInt

Calculates 2 raised to the power of the given exponent.

Parameters:

exponent

The exponent.

Returns:

A BigInt equal to 2^exponent.

statichashCode(this:BigInt_):Int

Generates a hash code for this BigInt.

Returns:

An integer hash code.

staticinlineisEven(this:BigInt_):Bool

Checks if this BigInt is an even number.

Returns:

true if the value is even, otherwise false.

staticinlineisNegative(this:BigInt_):Bool

Checks if this BigInt is a negative number.

Returns:

true if the value is less than 0, otherwise false.

staticinlineisOdd(this:BigInt_):Bool

Checks if this BigInt is an odd number.

Returns:

true if the value is odd, otherwise false.

staticinlineisPositive(this:BigInt_):Bool

Checks if this BigInt is a positive number.

Returns:

true if the value is greater than 0, otherwise false.

staticisProbablePrime(this:BigInt_, tolerance:UInt):Bool

Performs a primality test on this BigInt.

Parameters:

tolerance

The certainty level. A higher value means a more rigorous (but slower) test.

Returns:

true if the number is probably prime, false if it is definitely composite.

staticinlineisZero(this:BigInt_):Bool

Checks if this BigInt is equal to zero.

Returns:

true if the value is 0, otherwise false.

staticlcm(this:BigInt_, b:BigInt):BigInt

Finds the least common multiple (LCM) of this BigInt and another.

Parameters:

b

The other BigInt.

Returns:

The LCM of this and b.

staticinlinemax(this:BigInt_, other:BigInt):BigInt

Returns the maximum of this BigInt and another.

Parameters:

other

The BigInt to compare with.

Returns:

The larger of the two BigInt values.

staticinlinemin(this:BigInt_, other:BigInt):BigInt

Returns the minimum of this BigInt and another.

Parameters:

other

The BigInt to compare with.

Returns:

The smaller of the two BigInt values.

staticmodInverse(this:BigInt_, modulus:BigInt_):BigInt

Calculates the modular multiplicative inverse of this BigInt.

Parameters:

modulus

The modulus for the inverse operation.

Returns:

A new BigInt x such that (this * x) % modulus == 1.

staticmodPow(this:BigInt_, exponent:BigInt, modulus:BigInt):BigInt

Calculates (this ^ exponent) mod modulus.

Parameters:

exponent

The exponent.

modulus

The modulus.

Returns:

The result of the modular exponentiation.

staticnextProbablePrime(this:BigInt_):BigInt

Finds the first probable prime number greater than this BigInt.

Returns:

The next probable prime.

staticpow(this:BigInt_, exponent:UInt):BigInt

Raises this BigInt to the power of an integer exponent.

Parameters:

exponent

The non-negative exponent.

Returns:

A new BigInt representing this raised to the power of exponent.

staticinlinerandom(bits:Int32):BigInt

Generates a pseudo-random BigInt with a specified number of bits.

Parameters:

bits

The bit-length of the random number. The result is in the range [0, 2^bits - 1].

Returns:

A new BigInt with a random value.

staticrandomInRange(min:BigInt, max:BigInt):BigInt

Generates a pseudo-random BigInt within a given range.

Parameters:

min

The inclusive minimum value.

max

The inclusive maximum value.

Returns:

A random BigInt such that min <= result <= max.

staticrandomPrime(bits:Int32, tolerance:UInt):BigInt

Generates a probable prime number with a specified bit-length.

Parameters:

bits

The desired bit-length of the prime.

tolerance

The certainty level for the primality test.

Returns:

A probable prime BigInt.

staticsetBit(this:BigInt_, n:Int):BigInt

Returns a new BigInt with the specified bit set (to 1).

Parameters:

n

The index of the bit to set.

Returns:

A new BigInt with the bit set.

staticinlinesign(this:BigInt_):Int

Returns the sign of this BigInt.

Returns:

-1 if negative, 1 if positive, 0 if zero.

staticsquare(this:BigInt_):BigInt

Calculates the square of this BigInt.

Returns:

A new BigInt representing this * this.

statictestBit(this:BigInt_, n:Int):Bool

Tests if the bit at a given index is set.

Parameters:

n

The index of the bit to test.

Returns:

true if the bit is 1, otherwise false.

staticinlinetoBytes(this:BigInt_):Bytes

Converts this BigInt to a Bytes sequence (big-endian).

Returns:

A Bytes object representing the number's magnitude.

staticinlinetoHex(this:BigInt_):String

Returns the hexadecimal string representation of this BigInt. This is a shorthand for toString(16).

Returns:

The hexadecimal string.

staticinlinetoInts(this:BigInt_, output:Vector<Int>):Int

Converts this BigInt to a Vector of Ints.

Parameters:

output

The vector to write the integer words into.

Returns:

The number of words written to the vector.

@:value({ radix : 10 })staticinlinetoString(this:BigInt_, radix:Int = 10):String

Returns the string representation of this BigInt in the specified base.

Parameters:

radix

The base for the conversion (e.g., 10 for decimal, 16 for hexadecimal).

Returns:

The string representation of the number.