mini-gmp and mpq

Niels Möller nisse at
Wed Feb 14 21:08:52 UTC 2018

"Marco Bodrato" <bodrato at> writes:

> Il Mer, 14 Febbraio 2018 7:53 pm, Marco Bodrato ha scritto:
>> Ciao,
>> Il Mar, 13 Febbraio 2018 7:38 pm, Daniele Panozzo ha scritto:
>>> Is there any plan to extend mini-gmp to rationals (mpq)? This would
>>> really
>>> make it perfect for my use case.
>> Curious request. We sometimes discussed about modularising mini-gmp. This
>> request would benefit of such a modularisation.
>> It shouldn't be too difficoult to add the mpq layer; at least if you don't
>> need to deal with floats types nor strings.

I'm not sure what the use case was. I guess one could add an mpq.c
source file to the mini-gmp directory with mpq functions (that seems
like an appropriate level of modularization for this).

But another alternative with less code duplication might be to try to
build the existing mpq code, using mini-gmp for the underlying integer
arithmetic? I've neither hacked or used mpq, so I'm not sure how hard
that would be.

>From a quick look, I note that the total linecount of mpq/*.c is
considerably less than mini-gmp.c, and that the code uses very few mpn
functions, mpn_cmp, mpn_mul, mpn_tdiv_qr, mpn_get_d, mpn_rshift. Of
these, mpn_get_d and mpn_tdiv_qr are not provided by mini-gmp.


Niels Möller. PGP-encrypted email is preferred. Keyid 368C6677.
Internet email is subject to wholesale government surveillance.

More information about the gmp-devel mailing list