diff options
author | Marco Bodrato <bodrato@mail.dm.unipi.it> | 2013-01-23 22:29:35 +0100 |
---|---|---|
committer | Marco Bodrato <bodrato@mail.dm.unipi.it> | 2013-01-23 22:29:35 +0100 |
commit | 75cdc04caf91a73ec142306fcea92a969d99058d (patch) | |
tree | 1f73e89aade8249acc0bf3c5ca603e870d8ad4bf | |
parent | 1a190e74b77c1bf5dc8203d0862fd1d8b487e542 (diff) | |
download | gmp-75cdc04caf91a73ec142306fcea92a969d99058d.tar.gz |
mini-gmp/mini-gmp.c (mpz_cmpabs_d): Reindent, and move ABS inside the if.
-rw-r--r-- | mini-gmp/mini-gmp.c | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/mini-gmp/mini-gmp.c b/mini-gmp/mini-gmp.c index 41f48d059..8b6f07041 100644 --- a/mini-gmp/mini-gmp.c +++ b/mini-gmp/mini-gmp.c @@ -1551,35 +1551,36 @@ mpz_cmpabs_d (const mpz_t x, double d) double B, Bi; mp_size_t i; - xn = GMP_ABS (x->_mp_size); + xn = x->_mp_size; d = GMP_ABS (d); if (xn != 0) { - B = 2.0 * (double) GMP_LIMB_HIGHBIT; - Bi = 1.0 / B; + xn = GMP_ABS (xn); - /* Scale d so it can be compared with the top limb. */ - for (i = 1; i < xn; i++) - { - d *= Bi; - } - if (d >= B) - return -1; + B = 2.0 * (double) GMP_LIMB_HIGHBIT; + Bi = 1.0 / B; - /* Compare floor(d) to top limb, subtract and cancel when equal. */ - for (i = xn; i-- > 0;) - { - mp_limb_t f, xl; + /* Scale d so it can be compared with the top limb. */ + for (i = 1; i < xn; i++) + d *= Bi; - f = (mp_limb_t) d; - xl = x->_mp_d[i]; - if (xl > f) - return 1; - else if (xl < f) + if (d >= B) return -1; - d = B * (d - f); - } + + /* Compare floor(d) to top limb, subtract and cancel when equal. */ + for (i = xn; i-- > 0;) + { + mp_limb_t f, xl; + + f = (mp_limb_t) d; + xl = x->_mp_d[i]; + if (xl > f) + return 1; + else if (xl < f) + return -1; + d = B * (d - f); + } } return - (d > 0.0); } |