std.internal.math.biguintcore
Fundamental operations for arbitrary-precision arithmetic
These functions are for internal use only.
tmpl maxBigDigits
struct BigUint
fn add addAssignSimple addInt addOrSubAssignSimple addSimple adjustRemainder biguintFromDecimal biguintToDecimal biguintToHex biguintToOctal blockDivMod divModInternal firstNonZeroDigit getCacheLimit highestDifferentDigit highestPowerBelowUintMax highestPowerBelowUlongMax includeSign inplaceSub intpow itoaZeroPadded karatsubaRequiredBuffSize less mulInternal mulKaratsuba mulSimple recursiveDivMod removeLeadingZeros schoolbookDivMod squareInternal squareKaratsuba squareSimple sub subAssignSimple subInt toHexZeroPadded twosComplement
Types 3
aliasmultibyteAdd = multibyteAddSub!('+')
aliasmultibyteSub = multibyteAddSub!('-')
structBigUint
BigUint performs memory management and wraps the low-level calls.
Methods
char [] toHexString(int frontExtraBytes, char separator = 0,
int minPadding = 0, char padChar = '0',
LetterCase letterCase = LetterCase.upper) const pure nothrow @safe scopeConvert to a hex string, printing a minimum number of digits 'minPadding', allocating an additional 'frontExtraBytes' at the start of the string. Padding is done with padChar, which may be '0' or '...bool fromHexString(Range)(Range s) if (isBidirectionalRange!Range && isSomeChar!(ElementType!Range)) scopebool fromDecimalString(Range)(Range s) if (isForwardRange!Range && isSomeChar!(ElementType!Range)) scopevoid fromMagnitude(Range)(Range magnitude) if (isInputRange!Range
&& (isForwardRange!Range || hasLength!Range)
&& isUnsigned!(ElementType!Range)) scopeBigUint opBinary(string op, Tulong)(Tulong y) if (op == ">>" && is (Tulong == ulong)) pure nothrow @safe const return scopeBigUint opBinary(string op, Tulong)(Tulong y) if (op == "<<" && is (Tulong == ulong)) pure nothrow @safe const scopeBigUint addOrSubInt(Tulong)(const scope BigUint x, Tulong y, bool wantSub, ref bool sign) if (is(Tulong == ulong)) pure nothrow @safeBigUint divInt(T)(return scope BigUint x, T y_) if ( is(immutable T == immutable uint) ) pure nothrow @safeBigUint divInt(T)(scope BigUint x, T y) if ( is(immutable T == immutable ulong) ) pure nothrow @safevoid divMod(BigUint x, scope BigUint y,
out BigUint quotient, out BigUint remainder) pure nothrow @safeBigUint bitwiseOp(string op)(scope BigUint x, scope BigUint y, bool xSign, bool ySign, ref bool resultSign) if (op == "|" || op == "^" || op == "&") pure nothrow @safeFunctions 37
fn
BigDigit [] sub(const scope BigDigit [] x, const scope BigDigit [] y, bool * negative) pure nothrow @safefn
BigDigit [] subInt(const BigDigit[] x, ulong y) pure nothrow @safeReturn x - y. x must be greater than y.fn
void mulInternal(BigDigit[] result, const(BigDigit)[] x, const(BigDigit)[] y) pure nothrow @safeGeneral unsigned multiply routine for bigints. Sets result = x * y.fn
void squareInternal(BigDigit[] result, const BigDigit[] x) pure nothrow @safeGeneral unsigned squaring routine for BigInts. Sets result = x*x. NOTE: If the highest half-digit of x is zero, the highest digit of result will also be zero.fn
void divModInternal(BigDigit [] quotient, BigDigit[] remainder, const BigDigit [] u,
const BigDigit [] v) pure nothrow @safeif remainder is null, only calculate quotient.fn
char [] biguintToHex(return scope char [] buff, const scope BigDigit [] data, char separator = 0,
LetterCase letterCase = LetterCase.upper) pure nothrow @safefn
size_t biguintToOctal(char[] buff, const(BigDigit)[] data) pure nothrow @safe @nogcConvert a big uint into an octal string.fn
size_t biguintToDecimal(char [] buff, BigDigit [] data) pure nothrow @safeConvert a big uint into a decimal string.fn
int biguintFromDecimal(Range)(BigDigit[] data, Range s) if (
isInputRange!Range &&
isSomeChar!(ElementType!Range) &&
!isInfinite!Range)Convert a decimal string into a big uint.fn
void mulSimple(BigDigit[] result, const(BigDigit) [] left,
const(BigDigit)[] right) pure nothrow @safefn
uint addSimple(BigDigit[] result, const BigDigit [] left, const BigDigit [] right) pure nothrow @safefn
BigDigit addOrSubAssignSimple(BigDigit [] result, const(BigDigit) [] right,
bool wantSub) pure nothrow @safefn
void mulKaratsuba(BigDigit [] result, const(BigDigit) [] x,
const(BigDigit)[] y, BigDigit [] scratchbuff) pure nothrow @safefn
void squareKaratsuba(BigDigit [] result, const BigDigit [] x,
BigDigit [] scratchbuff) pure nothrow @safefn
void toHexZeroPadded(char[] output, uint value,
LetterCase letterCase = LetterCase.upper) pure nothrow @safefn
size_t highestDifferentDigit(const BigDigit [] left, const BigDigit [] right) pure nothrow @nogc @safefn
void recursiveDivMod(BigDigit[] quotient, BigDigit[] u, const(BigDigit)[] v,
BigDigit[] scratch, bool mayOverflow = false) pure nothrow @safefn
void adjustRemainder(BigDigit[] quot, BigDigit[] rem, const(BigDigit)[] v,
ptrdiff_t k,
BigDigit[] scratch, bool mayOverflow = false) pure nothrow @safeVariables 6
enumvar
FASTDIVLIMIT = 100enumvar
BigDigitBits = BigDigit.sizeof * 8var
BigDigit[] ZEROvar
BigDigit[] ONEvar
BigDigit[] TWOvar
BigDigit[] TENTemplates 1
tmplmaxBigDigits(T)
if (isIntegral!T)