diff options
-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; } |