std.bigint

Arbitrary-precision ('bignum') arithmetic.

Performance is optimized for numbers below ~1000 decimal digits. For X86 machines, highly optimised assembly routines are used.

The following algorithms are currently implemented:

  • Karatsuba multiplication
  • Squaring is optimized independently of multiplication
  • Divide-and-conquer division
  • Binary exponentiation

For very large numbers, consider using the GMP library instead.

Members

Functions

absUnsign
Unsigned!T absUnsign(T x)

Returns the absolute value of x converted to the corresponding unsigned type.

divMod
void divMod(BigInt dividend, BigInt divisor, BigInt quotient, BigInt remainder)

Finds the quotient and remainder for the given dividend and divisor in one operation.

powmod
BigInt powmod(BigInt base, BigInt exponent, BigInt modulus)

Fast power modulus calculation for BigInt operands.

toDecimalString
string toDecimalString(const(BigInt) x)
toHex
string toHex(const(BigInt) x)

Structs

BigInt
struct BigInt

A struct representing an arbitrary precision integer.

Meta

Authors

Don Clugston