summaryrefslogtreecommitdiff
path: root/mini-gmp
diff options
context:
space:
mode:
authorMarco Bodrato <bodrato@mail.dm.unipi.it>2020-09-11 00:56:45 +0200
committerMarco Bodrato <bodrato@mail.dm.unipi.it>2020-09-11 00:56:45 +0200
commit722a4e3dde2305ad86ae571ae35390058c690559 (patch)
treece261cc6d4ec2a565fd92973ba9dfc87c2970a13 /mini-gmp
parente3ecb552f6b1ff11e044c7311e4d36e6d0d928a6 (diff)
downloadgmp-722a4e3dde2305ad86ae571ae35390058c690559.tar.gz
mini-gmp/tests/t-mpq_double.c (mpq_get_d_exact_p): Cleanup
Diffstat (limited to 'mini-gmp')
-rw-r--r--mini-gmp/tests/t-mpq_double.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/mini-gmp/tests/t-mpq_double.c b/mini-gmp/tests/t-mpq_double.c
index 1bd6c92f5..f8409d5e9 100644
--- a/mini-gmp/tests/t-mpq_double.c
+++ b/mini-gmp/tests/t-mpq_double.c
@@ -58,13 +58,7 @@ mpz_get_d_exact_p (const mpz_t z)
int
mpq_get_d_exact_p (const mpq_t q)
{
- /* return mpq_mantissasizeinbits (q) <= DBL_MANT_DIG; */
- return
- (mpz_sizeinbase (mpq_denref (q), 2) -
- mpz_scan1 (mpq_denref (q), 0) == 1) &&
- (mpz_sizeinbase (mpq_numref (q), 2) -
- mpz_scan1 (mpq_numref (q), 0) <= DBL_MANT_DIG);
- /* mpz_sizeinbase (zero, 2) - mpz_scan1 (zero, 0) == 2 */
+ return mpq_mantissasizeinbits (q) <= DBL_MANT_DIG;
}
#define HAVE_EXACT_P 1
#endif
@@ -128,6 +122,9 @@ check_random (void)
d = ldexp ((double) m, e);
mpq_set_d (y, d);
+ if (i == 0)
+ mpq_neg (z, y);
+
mpq_add (y, y, z);
mpq_set_d (z, mpq_get_d (y));
f = mpq_get_d (z);