tests/mpq/t-get_d.c failure on m68k-linux

Niels Möller nisse at lysator.liu.se
Mon Feb 18 21:43:30 CET 2013


Aldy Hernandez <aldyh at redhat.com> writes:

> The problematic code in the test was:
>
>     d = my_ldexp (d, (int) (rp[LIMBS_PER_DOUBLE] % 1000) - 500);
>
>     __gmpq_set_d (q, d);
>     nd = __gmpz_get_d ((&((q)->_mp_num)));
>     dd = __gmpz_get_d ((&((q)->_mp_den)));
>
>     d2 = nd / dd;
>     if (d != d2)		<-- boo hiss!
>         return -1;

Maybe I'm naive, but does it help to simple change

  double d, d2, nd, dd;

at the top of that function to

  volatile double d, d2, nd, dd;

I mean, it shouldn't make much difference if excess precision is
discarded before or after it is passed as a return value from my_ldexp,
should it?

On the other hand, maybe the test ought to be rewritten. Using mpz_get_d
seems unnecessary. If I understand the code correctly, it constructs a
fraction a / 2^k which surely is representable as a double, and assigns
it to the double d using ldexp, and then assigns it to an mpq_t using
mpq_set_d.

Then it would make more sense to me to get back *integer* numerator and
denominator, say n / d, and then check that a * d = n*2^k.

Regards,
/Niels

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.


More information about the gmp-bugs mailing list