diff --git a/chicken.h b/chicken.h index 2ced110..456f1dc 100644 --- a/chicken.h +++ b/chicken.h @@ -2181,13 +2181,18 @@ C_inline int C_ub_i_fpintegerp(double x) C_inline C_word C_i_integerp(C_word x) { - double dummy; + double value, dummy; + + if (x & C_FIXNUM_BIT) + return C_SCHEME_TRUE; + if (C_immediatep(x) || C_block_header(x) != C_FLONUM_TAG) + return C_SCHEME_FALSE; - if(C_isnan(x) || C_isinf(x)) return C_SCHEME_FALSE; + value = C_flonum_magnitude(x); + + if(C_isnan(value) || C_isinf(value)) return C_SCHEME_FALSE; - return C_mk_bool((x & C_FIXNUM_BIT) || - ((!C_immediatep(x) && C_block_header(x) == C_FLONUM_TAG) && - C_modf(C_flonum_magnitude(x), &dummy) == 0.0 ) ); + return C_mk_bool(C_modf(value, &dummy) == 0.0 ); }