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)) static pure nothrow @safeBigUint addOrSub(scope BigUint x, scope BigUint y, bool wantSub, ref bool sign) static pure nothrow @safeBigUint divInt(T)(return scope BigUint x, T y_) if ( is(immutable T == immutable uint) ) static pure nothrow @safeBigUint divInt(T)(scope BigUint x, T y) if ( is(immutable T == immutable ulong) ) static pure nothrow @safevoid divMod(BigUint x, scope BigUint y,
out BigUint quotient, out BigUint remainder) static pure nothrow @safeBigUint bitwiseOp(string op)(scope BigUint x, scope BigUint y, bool xSign, bool ySign, ref bool resultSign) if (op == "|" || op == "^" || op == "&") static pure nothrow @safeFunctions 37
private fn
BigDigit[] includeSign(scope const(BigDigit) [] x, size_t minSize, bool sign) pure nothrow @safeprivate fn
BigDigit [] sub(const scope BigDigit [] x, const scope BigDigit [] y, bool * negative) pure nothrow @safeprivate fn
BigDigit [] subInt(const BigDigit[] x, ulong y) pure nothrow @safeReturn x - y. x must be greater than y.private fn
void mulInternal(BigDigit[] result, const(BigDigit)[] x, const(BigDigit)[] y) pure nothrow @safeGeneral unsigned multiply routine for bigints. Sets result = x * y.private 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.private fn
void divModInternal(BigDigit [] quotient, BigDigit[] remainder, const BigDigit [] u,
const BigDigit [] v) pure nothrow @safeif remainder is null, only calculate quotient.private fn
char [] biguintToHex(return scope char [] buff, const scope BigDigit [] data, char separator = 0,
LetterCase letterCase = LetterCase.upper) pure nothrow @safeprivate fn
size_t biguintToOctal(char[] buff, const(BigDigit)[] data) pure nothrow @safe @nogcConvert a big uint into an octal string.private fn
size_t biguintToDecimal(char [] buff, BigDigit [] data) pure nothrow @safeConvert a big uint into a decimal string.private fn
int biguintFromDecimal(Range)(BigDigit[] data, Range s) if (
isInputRange!Range &&
isSomeChar!(ElementType!Range) &&
!isInfinite!Range)Convert a decimal string into a big uint.private fn
void mulSimple(BigDigit[] result, const(BigDigit) [] left,
const(BigDigit)[] right) pure nothrow @safeprivate fn
uint addSimple(BigDigit[] result, const BigDigit [] left, const BigDigit [] right) pure nothrow @safeprivate fn
BigDigit addOrSubAssignSimple(BigDigit [] result, const(BigDigit) [] right,
bool wantSub) pure nothrow @safeprivate fn
bool inplaceSub(BigDigit[] result, const(BigDigit)[] x, const(BigDigit)[] y) pure nothrow @safeprivate fn
void mulKaratsuba(BigDigit [] result, const(BigDigit) [] x,
const(BigDigit)[] y, BigDigit [] scratchbuff) pure nothrow @safeprivate fn
void squareKaratsuba(BigDigit [] result, const BigDigit [] x,
BigDigit [] scratchbuff) pure nothrow @safeprivate fn
void schoolbookDivMod(BigDigit [] quotient, BigDigit [] u, in BigDigit [] v) pure nothrow @safeprivate fn
void toHexZeroPadded(char[] output, uint value,
LetterCase letterCase = LetterCase.upper) pure nothrow @safeprivate fn
size_t highestDifferentDigit(const BigDigit [] left, const BigDigit [] right) pure nothrow @nogc @safeprivate fn
void recursiveDivMod(BigDigit[] quotient, BigDigit[] u, const(BigDigit)[] v,
BigDigit[] scratch, bool mayOverflow = false) pure nothrow @safeprivate fn
void adjustRemainder(BigDigit[] quot, BigDigit[] rem, const(BigDigit)[] v,
ptrdiff_t k,
BigDigit[] scratch, bool mayOverflow = false) pure nothrow @safeprivate fn
void blockDivMod(BigDigit [] quotient, BigDigit [] u, in BigDigit [] v) pure nothrow @safeVariables 6
private enumvar
FASTDIVLIMIT = 100private enumvar
BigDigitBits = BigDigit.sizeof * 8Templates 1
tmplmaxBigDigits(T)
if (isIntegral!T)