fix (expt #t 0)
authorAndy Wingo <wingo@pobox.com>
Mon, 7 Jun 2010 21:27:55 +0000 (23:27 +0200)
committerAndy Wingo <wingo@pobox.com>
Mon, 7 Jun 2010 21:27:55 +0000 (23:27 +0200)
* libguile/numbers.c (scm_expt): Fix check regarding when to dispatch to
  integer-expt.

* test-suite/tests/numbers.test ("expt"): Add test.

libguile/numbers.c
test-suite/tests/numbers.test

index b1c918f..ca4330b 100644 (file)
@@ -5466,7 +5466,7 @@ SCM_DEFINE (scm_expt, "expt", 2, 0, 0,
            "Return @var{x} raised to the power of @var{y}.") 
 #define FUNC_NAME s_scm_expt
 {
-  if (!SCM_INEXACTP (y) && scm_is_integer (y))
+  if ((SCM_I_INUMP (x) || SCM_BIGP (x)) && scm_is_integer (y))
     return scm_integer_expt (x, y);
   else if (scm_is_real (x) && scm_is_real (y) && scm_to_double (x) >= 0.0)
     {
index 3f26712..fae86e4 100644 (file)
 ;;;
 
 (with-test-prefix "expt"
+  (pass-if-exception "non-numeric base" exception:wrong-type-arg
+                     (expt #t 0))
   (pass-if "(= 1 (expt 0 0))" (= 1 (expt 0 0)))
   (pass-if "(= 1 (expt 0 0.0))" (= 1 (expt 0 0.0)))
   (pass-if "(= 1 (expt 0.0 0))" (= 1 (expt 0.0 0)))