aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Belanger2004-11-29 22:41:10 +0000
committerJay Belanger2004-11-29 22:41:10 +0000
commit6adaed7889d350f8da83aa0e813a3d334985ac9f (patch)
tree9fedd4102e30215b983e0214ad893a1ce4600641
parent5f9e0ca5dae5a442a210735e6357977a6807b815 (diff)
downloademacs-6adaed7889d350f8da83aa0e813a3d334985ac9f.tar.gz
emacs-6adaed7889d350f8da83aa0e813a3d334985ac9f.zip
(math-pow-of-zero): Take into account different cases.
-rw-r--r--lisp/calc/calc-arith.el46
1 files changed, 29 insertions, 17 deletions
diff --git a/lisp/calc/calc-arith.el b/lisp/calc/calc-arith.el
index 84328233860..df9936a670b 100644
--- a/lisp/calc/calc-arith.el
+++ b/lisp/calc/calc-arith.el
@@ -1740,23 +1740,35 @@
1740 (math-normalize (list '^ a b))) 1740 (math-normalize (list '^ a b)))
1741 1741
1742(defun math-pow-of-zero (a b) 1742(defun math-pow-of-zero (a b)
1743 (if (Math-zerop b) 1743 "Raise A to the power of B, where A is a form of zero."
1744 (if calc-infinite-mode 1744 (if (math-floatp b) (setq a (math-float a)))
1745 '(var nan var-nan) 1745 (cond
1746 (math-reject-arg (list '^ a b) "*Indeterminate form")) 1746 ;; 0^0 = 1
1747 (if (math-floatp b) (setq a (math-float a))) 1747 ((eq b 0)
1748 (if (math-posp b) 1748 1)
1749 a 1749 ;; 0^0.0, etc., are undetermined
1750 (if (math-negp b) 1750 ((Math-zerop b)
1751 (math-div 1 a) 1751 (if calc-infinite-mode
1752 (if (math-infinitep b) 1752 '(var nan var-nan)
1753 '(var nan var-nan) 1753 (math-reject-arg (list '^ a b) "*Indeterminate form")))
1754 (if (and (eq (car b) 'intv) (math-intv-constp b) 1754 ;; 0^positive = 0
1755 calc-infinite-mode) 1755 ((math-posp b)
1756 '(intv 3 (neg (var inf var-inf)) (var inf var-inf)) 1756 a)
1757 (if (math-objectp b) 1757 ;; 0^negative is undefined (let math-div handle it)
1758 (list '^ a b) 1758 ((math-negp b)
1759 a))))))) 1759 (math-div 1 a))
1760 ;; 0^infinity is undefined
1761 ((math-infinitep b)
1762 '(var nan var-nan))
1763 ;; Some intervals
1764 ((and (eq (car b) 'intv)
1765 calc-infinite-mode
1766 (math-negp (nth 2 b))
1767 (math-posp (nth 3 b)))
1768 '(intv 3 (neg (var inf var-inf)) (var inf var-inf)))
1769 ;; If none of the above, leave it alone.
1770 (t
1771 (list '^ a b))))
1760 1772
1761(defun math-pow-zero (a b) 1773(defun math-pow-zero (a b)
1762 (if (eq (car-safe a) 'mod) 1774 (if (eq (car-safe a) 'mod)