Mercurial > emacs
changeset 81700:a92fa56df453
(calculator-expt): Use more cases to determine the value.
author | Jay Belanger <jay.p.belanger@gmail.com> |
---|---|
date | Wed, 04 Jul 2007 13:53:11 +0000 |
parents | 4e032ef87a13 |
children | 4dec588dee75 |
files | lisp/calculator.el |
diffstat | 1 files changed, 22 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/calculator.el Wed Jul 04 04:36:04 2007 +0000 +++ b/lisp/calculator.el Wed Jul 04 13:53:11 2007 +0000 @@ -1793,14 +1793,28 @@ (expt x y) (domain-error 0.0e+NaN) (range-error - (if (> y 0) - (if (and - (< x 0) - (= y (truncate y)) - (oddp (truncate y))) - -1.0e+INF - 1.0e+INF) - 0.0)) + (cond + ((and (< x 1.0) (> x -1.0)) + ;; For small x, the range error comes from large y. + 0.0) + ((and (> x 0.0) (< y 0.0)) + ;; For large positive x and negative y, the range error + ;; comes from large negative y. + 0.0) + ((and (> x 0.0) (> y 0.0)) + ;; For large positive x and positive y, the range error + ;; comes from large y. + 1.0e+INF) + ;; For the rest, x must be large and negative. + ;; The range errors come from large integer y. + ((< y 0.0) + 0.0) + ((oddp (truncate y)) + ;; If y is odd + -1.0e+INF) + (t + ;; + 1.0e+INF))) (error 0.0e+NaN))) (defun calculator-fact (x)