class

BigInt

const class BigInt : Obj

Immutable arbitrary-precision integer.

constructors makeInt

Returns a BigInt whose value is equal to that of the specified Int

fromStr

Parse a Str into a BigInt using the specified radix

makeBuf

Translates a byte array containing the two's-complement binary representation of a BigInt into a BigInt

fields zero

one

defVal

Default value is 0

methods minus

Subtract b from this

compare

Compare based on integer value

shiftl

Bitwise left shift of this by b

mod

Return remainder of this divided by b

mult

Multiply this with b

modInt

Return remainder of this divided by b

increment

Increment by one

multInt

Multiply this with b

setBit

Set the given bit to 1

div

Divide this by b

not

Bitwise not/inverse of this

min

Return the smaller of this and the specified BigInt values

and

Bitwise-and of this and b

shiftr

Bitwise arithmetic right-shift of this by b

pow

Return this value raised to the specified power

clearBit

Set the given bit to 0

xor

Bitwise-exclusive-or of this and b

toDecimal

Convert the number to an Decimal

plusInt

Add this with b

signum

-1, 0, 1 if the BigInt is negative, zero, or positive

toStr

Return decimal string representation

flipBit

Flip the given bit between 0 and 1

toInt

Convert the number to an Int

or

Bitwise-or of this and b

toRadix

Return string representation in given radix

max

Return the larger of this and the specified BigInt values

toFloat

Convert the number to an Float

testBit

Return true if given bit is 1

plus

Add this with b

toBuf

Returns a byte array containing the two's-complement representation of this BigInt

bitLen

Returns the number of bits in the minimal two's-complement representation of this BigInteger, excluding a sign bit

abs

Return the absolute value of this integer

decrement

Decrement by one

minusInt

Subtract b from this

negate

Negative of this

equals

Return true if same both represent that same integer value

divInt

Divide this by b

hash

The hash for a BigInt is platform dependent

abs BigInt abs()

Return the absolute value of this integer. If this value is positive then return this, otherwise return the negation.

and BigInt and(Obj b)

Bitwise-and of this and b.

bitLen Int bitLen()

Returns the number of bits in the minimal two's-complement representation of this BigInteger, excluding a sign bit.

clearBit BigInt clearBit(Int b)

Set the given bit to 0. Equivalent to this.and(1.shiftl(b).not).

compare virtual Int compare(Obj obj)

Compare based on integer value.

decrement @Operator
BigInt decrement()

Decrement by one. Shortcut is --a or a--.

defVal const static BigInt : defVal

Default value is 0.

div @Operator
BigInt div(BigInt b)

Divide this by b. Shortcut is a/b.

divInt @Operator
BigInt divInt(Int b)

Divide this by b. Shortcut is a/b.

equals virtual Bool equals(Obj? obj)

Return true if same both represent that same integer value.

flipBit BigInt flipBit(Int b)

Flip the given bit between 0 and 1. Equivalent to this.xor(1.shiftl(b)).

fromStr static new fromStr(Str s, Int radix, Bool checked)

Parse a Str into a BigInt using the specified radix. If invalid format and checked is false return null, otherwise throw ParseErr.

hash virtual Int hash()

The hash for a BigInt is platform dependent.

increment @Operator
BigInt increment()

Increment by one. Shortcut is ++a or a++.

makeBuf new makeBuf(Buf bytes)

Translates a byte array containing the two's-complement binary representation of a BigInt into a BigInt.

makeInt new makeInt(Int val)

Returns a BigInt whose value is equal to that of the specified Int.

max BigInt max(BigInt that)

Return the larger of this and the specified BigInt values.

min BigInt min(BigInt that)

Return the smaller of this and the specified BigInt values.

minus @Operator
BigInt minus(BigInt b)

Subtract b from this. Shortcut is a-b.

minusInt @Operator
BigInt minusInt(Int b)

Subtract b from this. Shortcut is a-b.

mod @Operator
BigInt mod(BigInt b)

Return remainder of this divided by b. Shortcut is a%b.

modInt @Operator
Int modInt(Int b)

Return remainder of this divided by b. Shortcut is a%b.

mult @Operator
BigInt mult(BigInt b)

Multiply this with b. Shortcut is a*b.

multInt @Operator
BigInt multInt(Int b)

Multiply this with b. Shortcut is a*b.

negate @Operator
BigInt negate()

Negative of this. Shortcut is -a.

not BigInt not()

Bitwise not/inverse of this.

one const static BigInt : one

or BigInt or(Obj b)

Bitwise-or of this and b.

plus @Operator
BigInt plus(BigInt b)

Add this with b. Shortcut is a+b.

plusInt @Operator
BigInt plusInt(Int b)

Add this with b. Shortcut is a+b.

pow BigInt pow(Int pow)

Return this value raised to the specified power. Throw ArgErr if pow is less than zero.

setBit BigInt setBit(Int b)

Set the given bit to 1. Equivalent to this.or(1.shiftl(b)).

shiftl BigInt shiftl(Int b)

Bitwise left shift of this by b. Negative values call shiftr instead.

shiftr BigInt shiftr(Int b)

Bitwise arithmetic right-shift of this by b. Note that this is similar to Int.shifta, not Int.shiftr. Sign extension is performed. Negative values call shiftl instead.

signum Int signum()

-1, 0, 1 if the BigInt is negative, zero, or positive.

testBit Bool testBit(Int b)

Return true if given bit is 1. Equivalent to this.and(1.shiftl(b)) != 0.

toBuf Buf toBuf()

Returns a byte array containing the two's-complement representation of this BigInt.

toDecimal Decimal toDecimal()

Convert the number to an Decimal.

This simply wraps the BigInt with Decimal with a 0 scale, equivilent mathematically to int * 2^0

toFloat Float toFloat()

Convert the number to an Float.

If the value is out-of-range, it will return Float.posInf or Float.negInf. Possible loss of precision is still possible, even if the value is finite.

toInt Int toInt(Bool checked)

Convert the number to an Int.

If the value is out-of-range and checked is true, an Err is thrown. Otherwise the value is truncated, with possible loss of sign.

toRadix Str toRadix(Int radix, Int? width)

Return string representation in given radix. If width is non-null, then leading zeros are prepended to ensure the specified width.

toStr virtual Str toStr()

Return decimal string representation.

xor BigInt xor(Obj b)

Bitwise-exclusive-or of this and b.

zero const static BigInt : zero

Haxall 4.0.5 ∙ 24-Feb-2026 14:33 EST