A mutable arbitrary-precision integer.

This abstract type provides in-place modification of a BigInt's value, which can be more efficient for operations that involve many intermediate steps, as it avoids repeated memory allocation.

Static methods

staticabs(this:MutableBigInt_):MutableBigInt

Converts this number to its absolute value, in place.

Returns:

This MutableBigInt instance.

staticbitLength(this:MutableBigInt_):Int

Returns the number of bits

Returns:

The bit length.

staticinlineclear(this:MutableBigInt_):Void

Resets the value of this MutableBigInt to zero.

staticinlinecopyFrom(this:MutableBigInt_, other:BigInt):Void

Copies the value from another BigInt into this one.

Parameters:

other

The BigInt to copy from.

staticfromBigEndianBytesUnsigned(value:Bytes):MutableBigInt

Creates a MutableBigInt from unsigned, big-endian bytes.

Parameters:

value

The Bytes to convert.

Returns:

A new MutableBigInt instance.

staticfromLittleEndianBytesUnsigned(value:Bytes):MutableBigInt

Creates a MutableBigInt from unsigned, little-endian bytes.

Parameters:

value

The Bytes to convert.

Returns:

A new MutableBigInt instance.

staticgcd(this:MutableBigInt_, b:BigInt):MutableBigInt

Calculates the GCD of this and another BigInt.

Parameters:

b

The other BigInt.

Returns:

A new MutableBigInt holding the result.

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

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

Parameters:

index

The index of the bit to get.

Returns:

1 if the bit is set, 0 otherwise.

staticgetLowestSetBit(this:MutableBigInt_):Int

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

Returns:

The bit index, or -1 if zero.

staticinlineisNegative(this:MutableBigInt_):Bool

Checks if this MutableBigInt is a negative number.

Returns:

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

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

Tests if this number is probably prime.

Parameters:

tolerance

Certainty level for the Miller-Rabin test.

Returns:

true if probably prime.

staticinlineisZero(this:MutableBigInt_):Bool

Checks if this MutableBigInt is equal to zero.

Returns:

true if the value is 0, otherwise false.

staticmodPow(this:MutableBigInt_, exponent:BigInt, modulus:BigInt):MutableBigInt

Calculates (this ^ exponent) mod modulus.

Parameters:

exponent

The exponent.

modulus

The modulus.

Returns:

A new MutableBigInt holding the result.

staticpow(this:MutableBigInt_, exponent:UInt):MutableBigInt

Raises this number to the power of exponent.

Parameters:

exponent

The non-negative exponent.

Returns:

A new MutableBigInt holding the result.

@:value({ length : 0, offset : 0 })staticinlinesetFromBigEndianBytesUnsigned(this:MutableBigInt_, value:Bytes, offset:Int = 0, length:Int = 0):Void

Sets the value from a Bytes sequence, interpreted as unsigned big-endian.

Parameters:

value

The source Bytes.

offset

The starting offset.

length

The number of bytes to read.

staticinlinesetFromInt(this:MutableBigInt_, value:Int):Void

Sets the value of this MutableBigInt from a standard Int.

Parameters:

value

The new integer value.

@:value({ length : 0, offset : 0 })staticinlinesetFromLittleEndianBytesUnsigned(this:MutableBigInt_, value:Bytes, offset:Int = 0, length:Int = 0):Void

Sets the value from a Bytes sequence, interpreted as unsigned little-endian.

Parameters:

value

The source Bytes.

offset

The starting offset.

length

The number of bytes to read.

@:value({ length : 0 })staticinlinesetFromUnsignedInts(this:MutableBigInt_, value:Vector<Int>, length:Int = 0):Void

Sets the value from a Vector of unsigned Int words.

Parameters:

value

The vector of integer words.

length

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

staticinlinesetFromVector(this:MutableBigInt_, source:Vector<Int32>, sourcePosition:Int, length:Int):Void

Sets the value from a portion of another Vector of Ints.

Parameters:

source

The source vector.

sourcePosition

The starting position in the source vector.

length

The number of words to copy.

staticinlinesign(this:MutableBigInt_):Int

Returns the sign of this MutableBigInt.

Returns:

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

staticinlinetoBytes(this:MutableBigInt_):Bytes

Converts this MutableBigInt to a Bytes sequence.

Returns:

A Bytes object representing the number.

staticinlinetoHex(this:MutableBigInt_):String

Returns the hexadecimal string representation of this MutableBigInt.

Returns:

The hexadecimal string.

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

Converts this MutableBigInt to a Vector of Ints.

Parameters:

output

The vector to write the integer words into.

Returns:

The number of words written.

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

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

Parameters:

radix

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

Returns:

The string representation of the number.