mini-gmp and mpq

Marco Bodrato bodrato at mail.dm.unipi.it
Sat Feb 24 21:45:40 UTC 2018


Ciao,

Il Dom, 18 Febbraio 2018 9:51 am, Niels Möller ha scritto:
> I was thinking that if many of the mpq functions are written with simple
> code on top of mpz_

> But I might be mistaken, e.g, mpq/aors.c look a lot more more complex
> than in your sketch of mini-mpq.c.

A new version is attached. It does not support any string conversion, no
{set,get,inp,out}_str, as the previous one. But I added some support for
the type double.

Does the following loop make sense to "shift" the float x until it
represents an integer?

      B = 2.0 * (double) GMP_LIMB_HIGHBIT;
      for (e = 0; x != x + 0.5; e += GMP_LIMB_BITS)
	x *= B;

I began writing some tests, so that I can also claim that the code should
be correct. It should be usable now...

Comments will be welcome!

Ĝis,
m

-- 
http://bodrato.it/papers/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mini-mpq.h
Type: text/x-chdr
Size: 2507 bytes
Desc: not available
URL: <https://gmplib.org/list-archives/gmp-devel/attachments/20180224/26dfb185/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mini-mpq.c
Type: text/x-csrc
Size: 6648 bytes
Desc: not available
URL: <https://gmplib.org/list-archives/gmp-devel/attachments/20180224/26dfb185/attachment-0003.bin>


More information about the gmp-devel mailing list