View source code
Display the source code in std/bigint.d from which this page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone.

Function std.bigint.divMod

Finds the quotient and remainder for the given dividend and divisor in one operation.

void divMod (
  const(BigInt) dividend,
  const(BigInt) divisor,
  out BigInt quotient,
  out BigInt remainder
) pure nothrow @safe;


dividend the BigInt to divide
divisor the BigInt to divide the dividend by
quotient is set to the result of the division
remainder is set to the remainder of the division


auto a = BigInt(123);
auto b = BigInt(25);
BigInt q, r;

divMod(a, b, q, r);

writeln(q); // 4
writeln(r); // 23
writeln(q * b + r); // a


Don Clugston


Boost License 1.0.