Behavior of mpf_eq near zero
Vincent Lefevre
vincent at vinc17.net
Mon Apr 13 09:51:36 UTC 2015
On 2015-04-13 11:31:03 +0200, tg at gmplib.org wrote:
> Alejandro Mallea <janoma at gmail.com> writes:
>
> The documentation says that mpf_eq(op1, op2, op3) "returns non-zero if
> the first op3 bits of op1 and op2 are equal", which makes me think
> equality is dangerously tied to the internal representation ("the
> first op3 bits"), but then it says "i.e., test if op1 and op2 are
> approximately equal.", but that is not happening in this case.
>
> The mpf_eq function is not well thought out, but I believe it works
> according to its documentation. Zero is only mpf_eq-equal to itself.
The manual poorly specifies this function since it doesn't say what
the first bits of a number are. For instance, the first 3 bits of
0.000
and
0.001
are "0.00" thus are equal. So, you need to introduce the concept
of normalization, and possibly take zero apart since it cannot be
normalized.
> Please don't use this function. At least use mpf_reldiff, or even
> better, use the mpfr GMP extension library.
I agree, though I really think that mpf_eq should be properly
specified. And how about saying that this function is obsolete
and planning to remove it in the future?
--
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