converting a mpq to a double

Andreas Fabri Andreas.Fabri at sophia.inria.fr
Fri Jun 10 14:56:40 CEST 2005


Hello again,

As the mathematical rational number is not necessarily
representable with a floating point number, I am wondering
if it is the closest one, or always the next smaller
or next larger one.

Obviosly underflow or overflow lead to problems GMP
cannot resolve.

andreas



Torbjorn Granlund wrote:
> Andreas Fabri <Andreas.Fabri at geometryfactory.com> writes:
> 
>   is there any kind of guarantee that the generated double is close
>   to the rational number op.
>   
> I am afraid I don't understand.
> 
> The returned `double' is supposed to be a good approximation,
> presumably within one ULP.  Whether that is "close" by your
> definition, I don't know.  There are also degenerate cases where
> the number is too large or too tiny for a `double'.
> 
> And I wouldn't dare to "guarantee" anything about the correctness
> of GMP (see also COPYING.LIB).
> 
> --
> Torbjörn
> _______________________________________________
> gmp-discuss mailing list
> gmp-discuss at swox.com
> https://gmplib.org/mailman/listinfo/gmp-discuss
> 



More information about the gmp-discuss mailing list