mirror of
https://github.com/dlang/phobos.git
synced 2025-04-29 14:40:30 +03:00
18 lines
No EOL
384 B
Text
18 lines
No EOL
384 B
Text
`divMod` was added to std.bigint.
|
|
|
|
$(REF divMod, std, bigint) calculates both the quotient and the remainder in one go:
|
|
|
|
-----
|
|
void divMod(const BigInt dividend, const BigInt divisor, out BigInt quotient, out BigInt remainder) pure nothrow
|
|
{
|
|
auto a = BigInt(123);
|
|
auto b = BigInt(25);
|
|
BigInt q, r;
|
|
|
|
divMod(a, b, q, r);
|
|
|
|
assert(q == 4);
|
|
assert(r == 23);
|
|
assert(q * b + r == a);
|
|
}
|
|
----- |