Skip to content
FutureBlitz

    Install

    Import std.math.big.bigint

    std.math.big.bigint

    BigInt: an integer of any size, over libtommath, which never changes once it's made. Its operators are an Int's, without overflow: / rounds toward 0, % takes the sign of what's divided, >> rounds down, and &, |, ^, and ~ work on two's complement, as wide as the numbers need. An Int64 on either side of one works too, so n + 1 and 2 * n do. A BigInt holds up to 2147483640 bits, about 646 million digits, as many as libtommath counts, and a result past that panics. A BigInt stays on its thread, so ToString and Parse are how one goes to another.

    std/math/big/bigint.fb

    Types

    BigInt class

    Public Class BigInt Implements Comparable, Hashable, Printable, Numeric

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

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

    • Public New(value: Int64) constructor #

      The BigInt of value.

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

      The number that adding leaves alone: 0.

      Doc from std.core.interfaces.Numeric.Zero.

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

      The number that multiplying leaves alone: 1.

      Doc from std.core.interfaces.Numeric.One.

    • @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 #

      Its hash, the same for values that are equal.

      Doc from std.core.interfaces.Hashable.Hash.

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

      Whether a and b are equal.

      Doc from std.core.interfaces.Equatable.Operator==.

    • 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 comes before b.

      Doc from std.core.interfaces.Comparable.Operator<.

    • 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 #

      b taken away from a.

      Doc from std.core.interfaces.Numeric.Operator-.

    • @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 and b multiplied together.

      Doc from std.core.interfaces.Numeric.Operator*.

    • @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.

      Doc from std.core.interfaces.Numeric.Operator/.

    • @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.