Import std.math.big.bigint
std.math.big.bigint
Integers of any size.
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.
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
-
The BigInt of
value. -
The zero BigInt, 0, which adding leaves alone.
-
The BigInt 1, which multiplying leaves alone.
-
The Double's whole part, as it is without what's after the point. A NaN or an infinity panics.
-
The integer the
bytesare, big-endian, which is 0 or more. Past the most bits a BigInt holds, it panics. -
The integer the
textis in theradix: 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. -
Its digits in base 10, after a "-" below 0.
-
Its digits in the
radix, those past 9 lowercase letters, after a "-" below 0. A radix outside 2 to 36 panics. -
Its bytes, big-endian, as few as hold it, so 0 has none. One below 0 panics.
-
It as an Int64, or Null outside an Int64's range.
-
The Double nearest it, ties to even, or an infinity past the largest Double.
-
-1, 0, or 1 as it's below, at, or above 0.
-
How many bits its magnitude takes: 0 for 0, and 8 for 255 and for -255.
-
Its distance from 0: the same BigInt, without its sign.
-
It to the power, modulo the
modulus: from 0 to below themodulus. An exponent below 0, or amodulusthat isn't above 0, panics. -
The number from 0 to below the
modulusthat times it is 1 modulo themodulus, or Null when there's none, since they share a factor. A modulus that isn't above 0 panics. -
The greatest number that divides both, which is 0 or more, and 0 only for two 0s.
-
The least number, 0 or more, that both divide, and 0 when either is 0.
-
Its square root, rounded down. One below 0 panics.
-
Its quotient and remainder by the
divisor, as / and % give them. A divisor of 0 panics. -
Whether it's prime by the Baillie-PSW test, which no composite number is known to pass, though some must.
-
A hash of its value, which BigInts that are equal share.
-
Whether
aandbare the same number. -
Whether
aandbare equal. -
Whether
aandbare equal. -
Whether
ais less thanb. -
Whether
acomes beforeb. -
Whether
acomes beforeb. -
Whether
acomes afterb. -
Whether
acomes afterb. -
Whether
acomes beforebor is equal to it. -
Whether
acomes beforebor is equal to it. -
Whether
acomes afterbor is equal to it. -
Whether
acomes afterbor is equal to it. -
aplusb, which panics past the most bits a BigInt holds. -
aplusb, which panics past the most bits a BigInt holds. -
aplusb, which panics past the most bits a BigInt holds. -
aminusb. Panics past the most bits a BigInt holds. -
aminusb, which panics past the most bits a BigInt holds. -
aminusb, which panics past the most bits a BigInt holds. -
atimesb. Panics past the most bits a BigInt holds. -
atimesb, which panics past the most bits a BigInt holds. -
atimesb, which panics past the most bits a BigInt holds. -
adivided byb, rounded toward 0. Abof 0 panics. -
adivided byb, rounded toward 0. Abof 0 panics. -
adivided byb, rounded toward 0. Abof 0 panics. -
What's left of
adivided byb, witha's sign, as an Int's % is. Abof 0 panics. -
What's left of
adivided byb, witha's sign, as an Int's % is. Abof 0 panics. -
What's left of
adivided byb, witha's sign, as an Int's % is. Abof 0 panics. -
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.
-
The bits that
aandbboth 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. -
The bits that
aandbboth 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. -
The bits that
aandbboth 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. -
The bits that
aorbhas, 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. -
The bits that
aorbhas, 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. -
The bits that
aorbhas, 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. -
The bits that one of
aandbhas, 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. -
The bits that one of
aandbhas, 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. -
The bits that one of
aandbhas, 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. -
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.
-
aover 2 to the powerb, rounded down, as an Int's >> is. A negativebpanics. -
anegated. -
awith 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.