diff options
| author | Jay Belanger | 2007-07-04 13:54:30 +0000 |
|---|---|---|
| committer | Jay Belanger | 2007-07-04 13:54:30 +0000 |
| commit | b4739e5db1d29f44b8ee3220476f53fa34a8b8d1 (patch) | |
| tree | d8ba172774f3a1bf1f42c0a844ac0796ab2de82b | |
| parent | aa9f2751768aa432534b99a674a9dce053c49649 (diff) | |
| download | emacs-b4739e5db1d29f44b8ee3220476f53fa34a8b8d1.tar.gz emacs-b4739e5db1d29f44b8ee3220476f53fa34a8b8d1.zip | |
(calculator-expt): Use more cases to determine the value.
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/calculator.el | 30 |
2 files changed, 27 insertions, 8 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 5f68d1e20a3..0912a5d6809 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2007-07-04 Jay Belanger <jay.p.belanger@gmail.com> | ||
| 2 | |||
| 3 | * calculator.el (calculator-expt): Use more cases to determine | ||
| 4 | the value. | ||
| 5 | |||
| 1 | 2007-07-03 Jay Belanger <jay.p.belanger@gmail.com> | 6 | 2007-07-03 Jay Belanger <jay.p.belanger@gmail.com> |
| 2 | 7 | ||
| 3 | * calculator.el (calculator-expt, calculator-integer-p): | 8 | * calculator.el (calculator-expt, calculator-integer-p): |
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." | |||
| 1793 | (expt x y) | 1793 | (expt x y) |
| 1794 | (domain-error 0.0e+NaN) | 1794 | (domain-error 0.0e+NaN) |
| 1795 | (range-error | 1795 | (range-error |
| 1796 | (if (> y 0) | 1796 | (cond |
| 1797 | (if (and | 1797 | ((and (< x 1.0) (> x -1.0)) |
| 1798 | (< x 0) | 1798 | ;; For small x, the range error comes from large y. |
| 1799 | (= y (truncate y)) | 1799 | 0.0) |
| 1800 | (oddp (truncate y))) | 1800 | ((and (> x 0.0) (< y 0.0)) |
| 1801 | -1.0e+INF | 1801 | ;; For large positive x and negative y, the range error |
| 1802 | 1.0e+INF) | 1802 | ;; comes from large negative y. |
| 1803 | 0.0)) | 1803 | 0.0) |
| 1804 | ((and (> x 0.0) (> y 0.0)) | ||
| 1805 | ;; For large positive x and positive y, the range error | ||
| 1806 | ;; comes from large y. | ||
| 1807 | 1.0e+INF) | ||
| 1808 | ;; For the rest, x must be large and negative. | ||
| 1809 | ;; The range errors come from large integer y. | ||
| 1810 | ((< y 0.0) | ||
| 1811 | 0.0) | ||
| 1812 | ((oddp (truncate y)) | ||
| 1813 | ;; If y is odd | ||
| 1814 | -1.0e+INF) | ||
| 1815 | (t | ||
| 1816 | ;; | ||
| 1817 | 1.0e+INF))) | ||
| 1804 | (error 0.0e+NaN))) | 1818 | (error 0.0e+NaN))) |
| 1805 | 1819 | ||
| 1806 | (defun calculator-fact (x) | 1820 | (defun calculator-fact (x) |