diff --git a/libguile/numbers.c b/libguile/numbers.c index d35bee005..22ec174db 100644 --- a/libguile/numbers.c +++ b/libguile/numbers.c @@ -503,15 +503,28 @@ SCM_DEFINE (scm_exact_p, "exact?", 1, 0, 0, "otherwise.") #define FUNC_NAME s_scm_exact_p { - if (SCM_I_INUMP (x)) - return SCM_BOOL_T; - if (SCM_BIGP (x)) - return SCM_BOOL_T; - if (SCM_FRACTIONP (x)) - return SCM_BOOL_T; - if (SCM_NUMBERP (x)) + if (SCM_INEXACTP (x)) return SCM_BOOL_F; - SCM_WRONG_TYPE_ARG (1, x); + else if (SCM_NUMBERP (x)) + return SCM_BOOL_T; + else + SCM_WRONG_TYPE_ARG (1, x); +} +#undef FUNC_NAME + + +SCM_DEFINE (scm_inexact_p, "inexact?", 1, 0, 0, + (SCM x), + "Return @code{#t} if @var{x} is an inexact number, @code{#f}\n" + "else.") +#define FUNC_NAME s_scm_inexact_p +{ + if (SCM_INEXACTP (x)) + return SCM_BOOL_T; + else if (SCM_NUMBERP (x)) + return SCM_BOOL_F; + else + SCM_WRONG_TYPE_ARG (1, x); } #undef FUNC_NAME @@ -3364,21 +3377,6 @@ SCM_DEFINE (scm_integer_p, "integer?", 1, 0, 0, #undef FUNC_NAME -SCM_DEFINE (scm_inexact_p, "inexact?", 1, 0, 0, - (SCM x), - "Return @code{#t} if @var{x} is an inexact number, @code{#f}\n" - "else.") -#define FUNC_NAME s_scm_inexact_p -{ - if (SCM_INEXACTP (x)) - return SCM_BOOL_T; - if (SCM_NUMBERP (x)) - return SCM_BOOL_F; - SCM_WRONG_TYPE_ARG (1, x); -} -#undef FUNC_NAME - - SCM scm_i_num_eq_p (SCM, SCM, SCM); SCM_PRIMITIVE_GENERIC (scm_i_num_eq_p, "=", 0, 2, 1, (SCM x, SCM y, SCM rest), diff --git a/test-suite/tests/numbers.test b/test-suite/tests/numbers.test index d9a75f3cc..27de0451b 100644 --- a/test-suite/tests/numbers.test +++ b/test-suite/tests/numbers.test @@ -240,7 +240,11 @@ (eq? #f (exact? (sqrt (- (expt fixnum-max 2) 1))))) (pass-if "sqrt ((fixnum-max+1)^2 - 1)" - (eq? #f (exact? (sqrt (- (expt (+ fixnum-max 1) 2) 1))))))) + (eq? #f (exact? (sqrt (- (expt (+ fixnum-max 1) 2) 1))))) + + (pass-if (not (exact? +inf.0))) + (pass-if (not (exact? -inf.0))) + (pass-if (not (exact? +nan.0))))) ;;; ;;; exp @@ -1559,6 +1563,9 @@ (pass-if (not (inexact? (- 1 fixnum-min)))) (pass-if (inexact? 1.3)) (pass-if (inexact? 3.1+4.2i)) + (pass-if (inexact? +inf.0)) + (pass-if (inexact? -inf.0)) + (pass-if (inexact? +nan.0)) (pass-if-exception "char" exception:wrong-type-arg (not (inexact? #\a)))