mini-gmp and mpq

Torbjörn Granlund tg at
Wed May 2 13:05:28 UTC 2018

Bradley Lucier <lucier at> writes:

  On 04/30/2018 04:06 AM, Marco Bodrato wrote:
  > Ciao,
  > Il Lun, 30 Aprile 2018 4:10 am, Bradley Lucier ha scritto:
  >>> On Apr 29, 2018, at 9:02 PM, Marco Bodrato <bodrato at>
  >>>> Il Dom, 29 Aprile 2018 8:24 pm, Bradley Lucier ha scritto:
  >> Looks good.  The important case is when a=b, but I just realized that the
  >> test can be refined to when the denominator of a is the denominator of b.
  > Interesting observation. But, do you think it's worth replacing
  >    if (a != b)
  > with
  >    if (mpz_cmp (mpq_denref (a), mpq_denref (b)))
  > ?


I am not so sure.  I have no idea how often the denominators will be
equal out there, but I'd expect that mpz_cmp would terminate in time
O(1) on average when they are not.

Please encrypt, key id 0xC8601622

More information about the gmp-devel mailing list