1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 11:40:18 +02:00

fix (expt #t 0)

* libguile/numbers.c (scm_expt): Fix check regarding when to dispatch to
  integer-expt.

* test-suite/tests/numbers.test ("expt"): Add test.
This commit is contained in:
Andy Wingo 2010-06-07 23:27:55 +02:00
parent 78f79f18e2
commit a4082ab57e
2 changed files with 3 additions and 1 deletions

View file

@ -5466,7 +5466,7 @@ SCM_DEFINE (scm_expt, "expt", 2, 0, 0,
"Return @var{x} raised to the power of @var{y}.") "Return @var{x} raised to the power of @var{y}.")
#define FUNC_NAME s_scm_expt #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); return scm_integer_expt (x, y);
else if (scm_is_real (x) && scm_is_real (y) && scm_to_double (x) >= 0.0) else if (scm_is_real (x) && scm_is_real (y) && scm_to_double (x) >= 0.0)
{ {

View file

@ -2875,6 +2875,8 @@
;;; ;;;
(with-test-prefix "expt" (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))" (= 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)))
(pass-if "(= 1 (expt 0.0 0))" (= 1 (expt 0.0 0))) (pass-if "(= 1 (expt 0.0 0))" (= 1 (expt 0.0 0)))