type

BigInt

src const class BigInt : Obj

Immutable arbitrary-precision integer.

constructors

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.

makeInt

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

fields

defVal

Default value is 0.

one
zero

methods

abs

Return the absolute value of this integer.

and

Bitwise-and of this and b.

bitLen

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

clearBit

Set the given bit to 0.

compare

Compare based on integer value.

decrement

Decrement by one.

div

Divide this by b.

divInt

Divide this by b.

equals

Return true if same both represent that same integer value.

flipBit

Flip the given bit between 0 and 1.

hash

The hash for a BigInt is platform dependent.

increment

Increment by one.

max

Return the larger of this and the specified BigInt values.

min

Return the smaller of this and the specified BigInt values.

minus

Subtract b from this.

minusInt

Subtract b from this.

mod

Return remainder of this divided by b.

modInt

Return remainder of this divided by b.

mult

Multiply this with b.

multInt

Multiply this with b.

negate

Negative of this.

not

Bitwise not/inverse of this.

or

Bitwise-or of this and b.

plus

Add this with b.

plusInt

Add this with b.

pow

Return this value raised to the specified power.

setBit

Set the given bit to 1.

shiftl

Bitwise left shift of this by b.

shiftr

Bitwise arithmetic right-shift of this by b.

signum

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

testBit

Return true if given bit is 1.

toBuf

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

toDecimal

Convert the number to an Decimal.

toFloat

Convert the number to an Float.

toInt

Convert the number to an Int.

toRadix

Return string representation in given radix.

toStr

Return decimal string representation.

xor

Bitwise-exclusive-or of this and b.

Slot Details

abs

src BigInt abs()

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

and

src BigInt and(Obj b)

Bitwise-and of this and b.

bitLen

src Int bitLen()

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

clearBit

src BigInt clearBit(Int b)

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

compare

src virtual override Int compare(Obj obj)

Compare based on integer value.

decrement

src @Operator
BigInt decrement()

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

defVal

src const static BigInt defVal

Default value is 0.

div

src @Operator
BigInt div(BigInt b)

Divide this by b. Shortcut is a/b.

divInt

src @Operator
BigInt divInt(Int b)

Divide this by b. Shortcut is a/b.

equals

src virtual override Bool equals(Obj? obj)

Return true if same both represent that same integer value.

flipBit

src BigInt flipBit(Int b)

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

fromStr

src static new fromStr(Str s, Int radix := 10, Bool checked := true)

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

hash

src virtual override Int hash()

The hash for a BigInt is platform dependent.

increment

src @Operator
BigInt increment()

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

makeBuf

src new makeBuf(Buf bytes)

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

makeInt

src new makeInt(Int val)

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

max

src BigInt max(BigInt that)

Return the larger of this and the specified BigInt values.

min

src BigInt min(BigInt that)

Return the smaller of this and the specified BigInt values.

minus

src @Operator
BigInt minus(BigInt b)

Subtract b from this. Shortcut is a-b.

minusInt

src @Operator
BigInt minusInt(Int b)

Subtract b from this. Shortcut is a-b.

mod

src @Operator
BigInt mod(BigInt b)

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

modInt

src @Operator
Int modInt(Int b)

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

mult

src @Operator
BigInt mult(BigInt b)

Multiply this with b. Shortcut is a*b.

multInt

src @Operator
BigInt multInt(Int b)

Multiply this with b. Shortcut is a*b.

negate

src @Operator
BigInt negate()

Negative of this. Shortcut is -a.

not

src BigInt not()

Bitwise not/inverse of this.

one

src const static BigInt one

or

src BigInt or(Obj b)

Bitwise-or of this and b.

plus

src @Operator
BigInt plus(BigInt b)

Add this with b. Shortcut is a+b.

plusInt

src @Operator
BigInt plusInt(Int b)

Add this with b. Shortcut is a+b.

pow

src BigInt pow(Int pow)

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

setBit

src BigInt setBit(Int b)

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

shiftl

src BigInt shiftl(Int b)

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

shiftr

src 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

src Int signum()

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

testBit

src Bool testBit(Int b)

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

toBuf

src Buf toBuf()

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

toDecimal

src 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

src 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

src Int toInt(Bool checked := true)

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

src Str toRadix(Int radix, Int? width := null)

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

toStr

src virtual override Str toStr()

Return decimal string representation.

xor

src BigInt xor(Obj b)

Bitwise-exclusive-or of this and b.

zero

src const static BigInt zero