+2007-07-04 Jay Belanger <jay.p.belanger@gmail.com>
+
+ * calculator.el (calculator-expt): Use more cases to determine
+ the value.
+
2007-07-03 Jay Belanger <jay.p.belanger@gmail.com>
* calculator.el (calculator-expt, calculator-integer-p):
(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)