BigInt.getDigit

Gets the nth number in the underlying representation that makes up the whole BigInt.

struct BigInt
const
T
getDigit
(
T = ulong
)
(
size_t n
)
if (
is(T == ulong) ||
is(T == uint)
)

Parameters

T

the type to view the underlying representation as

n size_t

The nth number to retrieve. Must be less than ulongLength or uintLength with respect to T.

Return Value

Type: T

The nth ulong in the representation of this BigInt.

Examples

auto a = BigInt("1000");
assert(a.ulongLength() == 1);
assert(a.getDigit(0) == 1000);

assert(a.uintLength() == 1);
assert(a.getDigit!uint(0) == 1000);

auto b = BigInt("2_000_000_000_000_000_000_000_000_000");
assert(b.ulongLength() == 2);
assert(b.getDigit(0) == 4584946418820579328);
assert(b.getDigit(1) == 108420217);

assert(b.uintLength() == 3);
assert(b.getDigit!uint(0) == 3489660928);
assert(b.getDigit!uint(1) == 1067516025);
assert(b.getDigit!uint(2) == 108420217);

Meta