diff options
author | Marco Bodrato <bodrato@mail.dm.unipi.it> | 2015-05-30 05:48:51 +0200 |
---|---|---|
committer | Marco Bodrato <bodrato@mail.dm.unipi.it> | 2015-05-30 05:48:51 +0200 |
commit | ba73f5955169a33d807328c28b74e0fe4e44467f (patch) | |
tree | e0663318ecba602fbb6bd00b1678dc286e688d47 /mpf | |
parent | cafad50c95118250dd52a9ed9e8bb4b83f30b125 (diff) | |
download | gmp-ba73f5955169a33d807328c28b74e0fe4e44467f.tar.gz |
mpf/int_p.c: Use a simpler loop to ignore zero limbs.
Diffstat (limited to 'mpf')
-rw-r--r-- | mpf/int_p.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/mpf/int_p.c b/mpf/int_p.c index 6144b70e3..48109d3e6 100644 --- a/mpf/int_p.c +++ b/mpf/int_p.c @@ -36,6 +36,7 @@ see https://www.gnu.org/licenses/. */ int mpf_integer_p (mpf_srcptr f) __GMP_NOTHROW { + mp_srcptr fp; mp_exp_t exp; mp_size_t size; @@ -44,7 +45,12 @@ mpf_integer_p (mpf_srcptr f) __GMP_NOTHROW if (exp <= 0) return (size == 0); /* zero is an integer, others have only fraction limbs */ + size = ABS (size); - /* any fraction limbs must be zero */ - return mpn_zero_p (PTR (f), ABS (size) - exp); + /* Ignore zeroes at the low end of F. */ + for (fp = PTR (f); *fp == 0; ++fp) + --size; + + /* no fraction limbs */ + return size <= exp; } |