# HG changeset patch # User Jay Belanger # Date 1183557191 0 # Node ID a92fa56df453582647eaf1af820e3f858368724b # Parent 4e032ef87a132ffc7ed55821c4ccc8f017966cbb (calculator-expt): Use more cases to determine the value. diff -r 4e032ef87a13 -r a92fa56df453 lisp/calculator.el --- 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)