Skip to content
FutureBlitz

    Install

    Import std.math.big.bigint

    BigInt

    std.math.big.bigint

    class

    Public Class BigInt Implements Comparable, Hashable, Printable, Numeric

    An integer of any size, which grows as it needs to.

    Examples

    Local big = BigInt(2) ** 100
    Expect(big.ToString() == "1267650600228229401496703205376")
    Expect(big % 7 == BigInt(2))
    Expect(BigInt.Parse("ff", 16) == BigInt(255))
    Expect(BigInt(97).IsProbablePrime())
    Expect(big.BitLength == 101)

    std/math/big/bigint.fb, line 62

    • Public New(value: Int64) constructor #

      The BigInt of value.

    • Public Static Method Zero(): BigInt static method #

      The zero BigInt, 0, which adding leaves alone.

    • Public Static Method One(): BigInt static method #

      The BigInt 1, which multiplying leaves alone.

    • @PanicsAtCaller Public Static Method FromDouble(value: Double): BigInt static method #

      The Double's whole part, as it is without what's after the point. A NaN or an infinity panics.

    • @PanicsAtCaller Public Static Method FromBytes(bytes: UInt8[]): BigInt static method #

      The integer the bytes are, big-endian, which is 0 or more. Past the most bits a BigInt holds, it panics.

    • @PanicsAtCaller Public Static Method Parse(text: String, radix: Int = 10): BigInt? static method #

      The integer the text is in the radix: a sign or none, then one or more digits, those past 9 letters of either case, as "-ff" is -255 in 16. Other text, or a number past the most bits a BigInt holds, is Null, and a radix outside 2 to 36 panics.

    • Public Method ToString(): String method #

      Its digits in base 10, after a "-" below 0.

    • @PanicsAtCaller Public Method ToString(radix: Int): String method #

      Its digits in the radix, those past 9 lowercase letters, after a "-" below 0. A radix outside 2 to 36 panics.

    • @PanicsAtCaller Public Method ToBytes(): UInt8[] method #

      Its bytes, big-endian, as few as hold it, so 0 has none. One below 0 panics.

    • Public Method ToInt64(): Int64? method #

      It as an Int64, or Null outside an Int64's range.

    • Public Method ToDouble(): Double method #

      The Double nearest it, ties to even, or an infinity past the largest Double.

    • Public Property Sign: Int property #

      -1, 0, or 1 as it's below, at, or above 0.

    • Public Property BitLength: Int64 property #

      How many bits its magnitude takes: 0 for 0, and 8 for 255 and for -255.

    • Public Method Abs(): BigInt method #

      Its distance from 0: the same BigInt, without its sign.

    • @PanicsAtCaller Public Method ModPow(exponent: BigInt, modulus: BigInt): BigInt method #

      It to the power, modulo the modulus: from 0 to below the modulus. An exponent below 0, or a modulus that isn't above 0, panics.

    • @PanicsAtCaller Public Method ModInverse(modulus: BigInt): BigInt? method #

      The number from 0 to below the modulus that times it is 1 modulo the modulus, or Null when there's none, since they share a factor. A modulus that isn't above 0 panics.

    • Public Method Gcd(other: BigInt): BigInt method #

      The greatest number that divides both, which is 0 or more, and 0 only for two 0s.

    • Public Method Lcm(other: BigInt): BigInt method #

      The least number, 0 or more, that both divide, and 0 when either is 0.

    • @PanicsAtCaller Public Method Sqrt(): BigInt method #

      Its square root, rounded down. One below 0 panics.

    • @PanicsAtCaller Public Method DivRem(divisor: BigInt): (BigInt, BigInt) method #

      Its quotient and remainder by the divisor, as / and % give them. A divisor of 0 panics.

    • Public Method IsProbablePrime(): Bool method #

      Whether it's prime by the Baillie-PSW test, which no composite number is known to pass, though some must.

    • Public Method Hash(): UInt64 method #

      A hash of its value, which BigInts that are equal share.

    • Operator ==(a: BigInt, b: BigInt): Bool operator #

      Whether a and b are the same number.

    • Operator ==(a: BigInt, b: Int64): Bool operator #

      Whether a and b are equal.

    • Operator ==(a: Int64, b: BigInt): Bool operator #

      Whether a and b are equal.

    • Operator <(a: BigInt, b: BigInt): Bool operator #

      Whether a is less than b.

    • Operator <(a: BigInt, b: Int64): Bool operator #

      Whether a comes before b.

    • Operator <(a: Int64, b: BigInt): Bool operator #

      Whether a comes before b.

    • Operator >(a: BigInt, b: Int64): Bool operator #

      Whether a comes after b.

    • Operator >(a: Int64, b: BigInt): Bool operator #

      Whether a comes after b.

    • Operator <=(a: BigInt, b: Int64): Bool operator #

      Whether a comes before b or is equal to it.

    • Operator <=(a: Int64, b: BigInt): Bool operator #

      Whether a comes before b or is equal to it.

    • Operator >=(a: BigInt, b: Int64): Bool operator #

      Whether a comes after b or is equal to it.

    • Operator >=(a: Int64, b: BigInt): Bool operator #

      Whether a comes after b or is equal to it.

    • @PanicsAtCaller Operator +(a: BigInt, b: BigInt): BigInt operator #

      a plus b, which panics past the most bits a BigInt holds.

    • @PanicsAtCaller Operator +(a: BigInt, b: Int64): BigInt operator #

      a plus b, which panics past the most bits a BigInt holds.

    • @PanicsAtCaller Operator +(a: Int64, b: BigInt): BigInt operator #

      a plus b, which panics past the most bits a BigInt holds.

    • @PanicsAtCaller Operator -(a: BigInt, b: BigInt): BigInt operator #

      a minus b. Panics past the most bits a BigInt holds.

    • @PanicsAtCaller Operator -(a: BigInt, b: Int64): BigInt operator #

      a minus b, which panics past the most bits a BigInt holds.

    • @PanicsAtCaller Operator -(a: Int64, b: BigInt): BigInt operator #

      a minus b, which panics past the most bits a BigInt holds.

    • @PanicsAtCaller Operator *(a: BigInt, b: BigInt): BigInt operator #

      a times b. Panics past the most bits a BigInt holds.

    • @PanicsAtCaller Operator *(a: BigInt, b: Int64): BigInt operator #

      a times b, which panics past the most bits a BigInt holds.

    • @PanicsAtCaller Operator *(a: Int64, b: BigInt): BigInt operator #

      a times b, which panics past the most bits a BigInt holds.

    • @PanicsAtCaller Operator /(a: BigInt, b: BigInt): BigInt operator #

      a divided by b, rounded toward 0. A b of 0 panics.

    • @PanicsAtCaller Operator /(a: BigInt, b: Int64): BigInt operator #

      a divided by b, rounded toward 0. A b of 0 panics.

    • @PanicsAtCaller Operator /(a: Int64, b: BigInt): BigInt operator #

      a divided by b, rounded toward 0. A b of 0 panics.

    • @PanicsAtCaller Operator %(a: BigInt, b: BigInt): BigInt operator #

      What's left of a divided by b, with a's sign, as an Int's % is. A b of 0 panics.

    • @PanicsAtCaller Operator %(a: BigInt, b: Int64): BigInt operator #

      What's left of a divided by b, with a's sign, as an Int's % is. A b of 0 panics.

    • @PanicsAtCaller Operator %(a: Int64, b: BigInt): BigInt operator #

      What's left of a divided by b, with a's sign, as an Int's % is. A b of 0 panics.

    • @PanicsAtCaller Operator **(a: BigInt, b: Int64): BigInt operator #

      To the power, which is 0 or more, as an Int's: a negative one panics, and so does a result past the most bits a BigInt holds, though 0, 1, and -1 go to any power.

    • @PanicsAtCaller Operator &(a: BigInt, b: BigInt): BigInt operator #

      The bits that a and b both have, in two's complement, which can take a negative number's magnitude a bit past either's, so it panics past the most bits a BigInt holds.

    • @PanicsAtCaller Operator &(a: BigInt, b: Int64): BigInt operator #

      The bits that a and b both have, in two's complement, which can take a negative number's magnitude a bit past either's, so it panics past the most bits a BigInt holds.

    • @PanicsAtCaller Operator &(a: Int64, b: BigInt): BigInt operator #

      The bits that a and b both have, in two's complement, which can take a negative number's magnitude a bit past either's, so it panics past the most bits a BigInt holds.

    • @PanicsAtCaller Operator |(a: BigInt, b: BigInt): BigInt operator #

      The bits that a or b has, in two's complement, which can take a negative number's magnitude a bit past either's, so it panics past the most bits a BigInt holds.

    • @PanicsAtCaller Operator |(a: BigInt, b: Int64): BigInt operator #

      The bits that a or b has, in two's complement, which can take a negative number's magnitude a bit past either's, so it panics past the most bits a BigInt holds.

    • @PanicsAtCaller Operator |(a: Int64, b: BigInt): BigInt operator #

      The bits that a or b has, in two's complement, which can take a negative number's magnitude a bit past either's, so it panics past the most bits a BigInt holds.

    • @PanicsAtCaller Operator ^(a: BigInt, b: BigInt): BigInt operator #

      The bits that one of a and b has, but not both, in two's complement, which can take a negative number's magnitude a bit past either's, so it panics past the most bits a BigInt holds.

    • @PanicsAtCaller Operator ^(a: BigInt, b: Int64): BigInt operator #

      The bits that one of a and b has, but not both, in two's complement, which can take a negative number's magnitude a bit past either's, so it panics past the most bits a BigInt holds.

    • @PanicsAtCaller Operator ^(a: Int64, b: BigInt): BigInt operator #

      The bits that one of a and b has, but not both, in two's complement, which can take a negative number's magnitude a bit past either's, so it panics past the most bits a BigInt holds.

    • @PanicsAtCaller Operator <<(a: BigInt, b: Int64): BigInt operator #

      Shifted by a count of bits, 0 or more, which a negative one panics, as an Int's does when it's outside its bits. Shifting left past the most bits a BigInt holds panics too, unless it's 0.

    • @PanicsAtCaller Operator >>(a: BigInt, b: Int64): BigInt operator #

      a over 2 to the power b, rounded down, as an Int's >> is. A negative b panics.

    • Operator -(a: BigInt): BigInt operator #

      a negated.

    • @PanicsAtCaller Operator ~(a: BigInt): BigInt operator #

      a with each of its bits flipped, in two's complement, which is -a - 1 and panics past the most bits a BigInt holds.

    Report an issue with this page or with FutureBlitz on GitHub.