Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Mathematical Functions

Exponentiation

print(BInt(2).power(100))    # 2^100
print(BInt(2) ** 100)         # Same via ** operator

Both power(exponent: Int) and power(exponent: BigInt) are supported. The exponent must be non-negative.

Integer square root

var x = BInt("100000000000000000000")
print(x.sqrt())    # 10000000000 (largest y such that y² ≤ x)
print(x.isqrt())   # Same as sqrt()

Raises if the value is negative.