mpz_ndiv_qr wanted
paul zimmermann
Paul.Zimmermann at inria.fr
Fri Sep 18 18:04:36 UTC 2015
Dear GMP developers,
after having written ten times (if not hundred) a function that computes an
integer quotient and remainder with rounding to nearest, I believe this could
be a nice addition to GMP, and useful to other users too.
I propose:
-- Function: void mpz_ndiv_qr (mpz_t Q, mpz_t R, const mpz_t N, const mpz_t D)
Divide N by D, forming a quotient Q and/or remainder R such that
N = Q*D + R. The quotient Q is rounded to nearest, i.e., either
|R| < D/2, or if |R| = D/2, then Q is even (can occur only for even D).
and of course the corresponding mpz_ndiv_q and mpz_ndiv_r functions.
(The tie-breaking rule for the case |R| = D/2 comes from IEEE 754.)
Best regards,
Paul
More information about the gmp-devel
mailing list