Contributing to GMP

Marco Bodrato bodrato at mail.dm.unipi.it
Wed Feb 26 10:13:08 UTC 2020


Ciao,

Il Lun, 24 Febbraio 2020 2:51 pm, Marc Glisse ha scritto:
> On Mon, 24 Feb 2020, Marco Bodrato wrote:

>> Of course, if you don't care to obtain sqrt(9/49) = 3/7 or anything
>> different...
>
> If you are going to approximate sqrt(2) with a rational, you probably
> don't care that much about getting exactly 3/7 either.

True, but 3/7 is more efficient for the following computations :-)

>> Well, also mpz_sqrt is not exact :-)
>
> I see it more like division: you can see integer division as inexact, or
> as a different operation (division with remainder).

That's an interesting point of view.

>> But of course, with mpq, we can decide how to approximate.
>
> By the way, maybe the function could return a bool (exact or not) or
> {-1,0,+1} to say in which direction it approximated.

That's the easy part. But one may also want to let the caller decide the
desired direction of approximation. Efficiency is much more tricky.

Ĝis,
m
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mpq_sqrt.c
Type: text/x-csrc
Size: 3931 bytes
Desc: not available
URL: <https://gmplib.org/list-archives/gmp-discuss/attachments/20200226/f5b550e5/attachment-0001.bin>


More information about the gmp-discuss mailing list