diff options
author | Jay Belanger <jay.p.belanger@gmail.com> | 2007-07-04 13:54:30 +0000 |
---|---|---|
committer | Jay Belanger <jay.p.belanger@gmail.com> | 2007-07-04 13:54:30 +0000 |
commit | b4739e5db1d29f44b8ee3220476f53fa34a8b8d1 (patch) | |
tree | d8ba172774f3a1bf1f42c0a844ac0796ab2de82b /lisp/calculator.el | |
parent | aa9f2751768aa432534b99a674a9dce053c49649 (diff) | |
download | emacs-b4739e5db1d29f44b8ee3220476f53fa34a8b8d1.tar.gz |
(calculator-expt): Use more cases to determine the value.
Diffstat (limited to 'lisp/calculator.el')
-rw-r--r-- | lisp/calculator.el | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/lisp/calculator.el b/lisp/calculator.el index c1e0edb6276..b0e3069d3e1 100644 --- a/lisp/calculator.el +++ b/lisp/calculator.el @@ -1793,14 +1793,28 @@ To use this, apply a binary operator (evaluate it), then call this." (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) |