Fundamental operations for arbitrary-precision arithmetic
These functions are for internal use only.
BSD style: see
license.txt
Don Clugston
- struct BigUint [public] ¶#
-
BigUint performs memory management and wraps the low-level calls.
- void opAssign(uint u) [public] ¶#
- int opCmp(BigUint y) [public] ¶#
- int opCmp(ulong y) [public] ¶#
- BigUint opShr(ulong y) [public] ¶#
- BigDigit [] addInt(BigDigit[] x, ulong y) [private] ¶#
-
return x + y
- BigDigit [] subInt(BigDigit[] x, ulong y) [private] ¶#
-
Return x - y.
x must be greater than y.
- void mulInternal(BigDigit[] result, BigDigit[] x, BigDigit[] y) [private] ¶#
-
General unsigned multiply routine for bigints.
Sets result = x * y.
The length of y must not be larger than the length of x.
Different algorithms are used, depending on the lengths of x and y.
- void divModInternal(BigDigit [] quotient, BigDigit[] remainder, BigDigit [] u, BigDigit [] v) [private] ¶#
-
if remainder is null, only calculate quotient.
- int biguintToDecimal(char [] buff, BigDigit [] data) [private] ¶#
-
Convert a big uint into a decimal string.
| buff | data The biguint to be converted. Will be destroyed.
buff The destination buffer for the decimal string. Must be
large enough to store the result, including leading zeros.
Will be filled backwards, starting from buff[$-1].
buff.length must be >= (data.length*32)/log2(10) = 9.63296 * data.length. |
the lowest index of buff which was used.
- int biguintFromDecimal(BigDigit [] data, char [] s) [private] ¶#
-
Convert a decimal string into a big uint.
| data The biguint to be receive the result. Must be large enough to
store the result.
s The decimal string. May contain 0..9, or _. Will be preserved.
The required length for the destination buffer is slightly less than
1 + s.length/log2(10) = 1 + s.length/3.3219. |
the highest index of data which was used.