Simple divisions returning yes/no remainder?

Paul Zimmermann Paul.Zimmermann at
Mon Nov 16 14:26:39 UTC 2020

       Dear Carl,

as the documentation says, the 'q' functions calculate only the quotient,
if you need the remainder too you should use the 'qr' functions.

Knowing whether the remainder is non-zero might require additional
computations, which might slow down the 'q' functions, which is something
you definitively don't want.

Best regards,
Paul Zimmermann

> From: Carl Ponder <cponder at>
> Date: Mon, 16 Nov 2020 08:08:46 -0600
> I'm using these functions to compute some rounded integer quotients
>     Function: /void/ *mpz_cdiv_q* /(mpz_t q, const mpz_t n, const mpz_t d)/
>     Function: /void/ *mpz_fdiv_q* /(mpz_t q, const mpz_t n, const mpz_t d)/
> I'd also like to know, though, if the remainder is non-zero without 
> having to perform additional arithmetic steps.
> Would it be possible for these functions to return a boolean for this?
> I expect that the algorithm would have some state-information that would 
> be easy to test at the end of the calculation, as opposed to performing 
> extra arithmetic.
> Thanks,
>                      Carl
> _______________________________________________
> gmp-discuss mailing list
> gmp-discuss at

More information about the gmp-discuss mailing list