Floor function for rationals available?

Torbjörn Granlund tg at gmplib.org
Mon Jun 22 11:41:37 UTC 2015

Moritz Schmitt <gmp at schmi.tt> writes:

  I am using GMP with C, and I am looking for a floor function for rationals,
  i.e., something like mpq_floor(). However, I can't seem to find it.
  Of course one could program such a function by hand by extracting the nominator
  and denominator, dividing, comparing, etc. But is this really the way to go?
You need mpz_set_q.  If you then need to get this mpz type as an
(intergral) mpq, you need to assign it back (possibly using the
low-level functions operating on the numerator).

Please encrypt, key id 0xC8601622

More information about the gmp-discuss mailing list