Behavior of mpf_eq near zero

Vincent Lefevre vincent at vinc17.net
Tue Apr 14 09:28:20 UTC 2015


On 2015-04-13 23:22:50 -0300, Alejandro Mallea wrote:
> By the way, should I be worried about finding similar behavoir rin MPFR?

Normally no, except well-documented particular cases for compatibility
with MPF. Here concerning mpf_eq, there is mpfr_eq, but documented as:

 -- Function: int mpfr_eq (mpfr_t OP1, mpfr_t OP2, unsigned long int OP3)
     Return non-zero if OP1 and OP2 are both non-zero ordinary numbers
     with the same exponent and the same first OP3 bits, both zero, or
     both infinities of the same sign. Return zero otherwise.  This
     function is defined for compatibility with MPF, we do not recommend
     to use it otherwise.  Do not use it either if you want to know
     whether two numbers are close to each other; for instance,
     1.011111 and 1.100000 are regarded as different for any value of
     OP3 larger than 1.

So, it's clear that it is only there for compatibility with MPF,
and that otherwise you shouldn't use it.

-- 
Vincent Lefèvre <vincent at vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


More information about the gmp-discuss mailing list