BigInt
const class BigInt : Obj
Immutable arbitrary-precision integer.
Parse a Str into a BigInt using the specified radix
Translates a byte array containing the two's-complement binary representation of a BigInt into a BigInt
Returns a BigInt whose value is equal to that of the specified Int
Default value is 0
Return the absolute value of this integer
Bitwise-and of this and b
Returns the number of bits in the minimal two's-complement representation of this BigInteger, excluding a sign bit
Set the given bit to 0
Compare based on integer value
Decrement by one
Divide this by b
Divide this by b
Return true if same both represent that same integer value
Flip the given bit between 0 and 1
The hash for a BigInt is platform dependent
Increment by one
Return the larger of this and the specified BigInt values
Return the smaller of this and the specified BigInt values
Subtract b from this
Subtract b from this
Return remainder of this divided by b
Return remainder of this divided by b
Multiply this with b
Multiply this with b
Negative of this
Bitwise not/inverse of this
Bitwise-or of this and b
Add this with b
Add this with b
Return this value raised to the specified power
Set the given bit to 1
Bitwise left shift of this by b
Bitwise arithmetic right-shift of this by b
-1, 0, 1 if the BigInt is negative, zero, or positive
Return true if given bit is 1
Returns a byte array containing the two's-complement representation of this BigInt
Convert the number to an Decimal
Convert the number to an Float
Convert the number to an Int
Return string representation in given radix
Return decimal string representation
Bitwise-exclusive-or of this and b
BigInt abs()
Return the absolute value of this integer. If this value is positive then return this, otherwise return the negation.
BigInt and(Obj b)
Bitwise-and of this and b.
Int bitLen()
Returns the number of bits in the minimal two's-complement representation of this BigInteger, excluding a sign bit.
BigInt clearBit(Int b)
Set the given bit to 0. Equivalent to this.and(1.shiftl(b).not).
virtual Int compare(Obj obj)
Compare based on integer value.
@Operator
BigInt decrement()
Decrement by one. Shortcut is --a or a--.
const static BigInt : defVal
Default value is 0.
@Operator
BigInt div(BigInt b)
Divide this by b. Shortcut is a/b.
@Operator
BigInt divInt(Int b)
Divide this by b. Shortcut is a/b.
virtual Bool equals(Obj? obj)
Return true if same both represent that same integer value.
BigInt flipBit(Int b)
Flip the given bit between 0 and 1. Equivalent to this.xor(1.shiftl(b)).
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.
virtual Int hash()
The hash for a BigInt is platform dependent.
@Operator
BigInt increment()
Increment by one. Shortcut is ++a or a++.
new makeBuf(Buf bytes)
Translates a byte array containing the two's-complement binary representation of a BigInt into a BigInt.
new makeInt(Int val)
Returns a BigInt whose value is equal to that of the specified Int.
BigInt max(BigInt that)
Return the larger of this and the specified BigInt values.
BigInt min(BigInt that)
Return the smaller of this and the specified BigInt values.
@Operator
BigInt minus(BigInt b)
Subtract b from this. Shortcut is a-b.
@Operator
BigInt minusInt(Int b)
Subtract b from this. Shortcut is a-b.
@Operator
BigInt mod(BigInt b)
Return remainder of this divided by b. Shortcut is a%b.
@Operator
Int modInt(Int b)
Return remainder of this divided by b. Shortcut is a%b.
@Operator
BigInt mult(BigInt b)
Multiply this with b. Shortcut is a*b.
@Operator
BigInt multInt(Int b)
Multiply this with b. Shortcut is a*b.
@Operator
BigInt negate()
Negative of this. Shortcut is -a.
BigInt not()
Bitwise not/inverse of this.
const static BigInt : one
BigInt or(Obj b)
Bitwise-or of this and b.
@Operator
BigInt plus(BigInt b)
Add this with b. Shortcut is a+b.
@Operator
BigInt plusInt(Int b)
Add this with b. Shortcut is a+b.
BigInt pow(Int pow)
Return this value raised to the specified power. Throw ArgErr if pow is less than zero.
BigInt setBit(Int b)
Set the given bit to 1. Equivalent to this.or(1.shiftl(b)).
BigInt shiftl(Int b)
Bitwise left shift of this by b. Negative values call shiftr instead.
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.
Int signum()
-1, 0, 1 if the BigInt is negative, zero, or positive.
Bool testBit(Int b)
Return true if given bit is 1. Equivalent to this.and(1.shiftl(b)) != 0.
Buf toBuf()
Returns a byte array containing the two's-complement representation of this BigInt.
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
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.
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.
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.
virtual Str toStr()
Return decimal string representation.
BigInt xor(Obj b)
Bitwise-exclusive-or of this and b.
const static BigInt : zero