diff options
author | Vincent Belaïche <vincent.belaiche@gmail.com> | 2010-04-06 20:33:00 -0500 |
---|---|---|
committer | Jay Belanger <jay.p.belanger@gmail.com> | 2010-04-06 20:33:00 -0500 |
commit | 317a26be001283988504d544692930af75a92e53 (patch) | |
tree | f9e071fe52d64ab3177ffef1c26c7448a7fdd6bc | |
parent | cb1b04a5d87eb8e4e72dbcc99d8555992c7765dc (diff) | |
download | emacs-317a26be001283988504d544692930af75a92e53.tar.gz |
(calcFunc-fdiv): Allow `fdiv' to divide fractions.
-rw-r--r-- | lisp/calc/calc-frac.el | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/lisp/calc/calc-frac.el b/lisp/calc/calc-frac.el index a01f5b8b9fa..d1164bec3c5 100644 --- a/lisp/calc/calc-frac.el +++ b/lisp/calc/calc-frac.el @@ -205,16 +205,32 @@ n temp)) (math-div n d))) - - (defun calcFunc-fdiv (a b) ; [R I I] [Public] - (if (Math-num-integerp a) - (if (Math-num-integerp b) - (if (Math-zerop b) - (math-reject-arg a "*Division by zero") - (math-make-frac (math-trunc a) (math-trunc b))) - (math-reject-arg b 'integerp)) - (math-reject-arg a 'integerp))) + (cond + ((Math-num-integerp a) + (cond + ((Math-num-integerp b) + (if (Math-zerop b) + (math-reject-arg a "*Division by zero") + (math-make-frac (math-trunc a) (math-trunc b)))) + ((eq (car-safe b) 'frac) + (if (Math-zerop (cadr b)) + (math-reject-arg a "*Division by zero") + (math-make-frac (math-mul (math-trunc a) (caddr b)) (cadr b)))) + (t (math-reject-arg b 'integerp)))) + ((eq (car-safe a) 'frac) + (cond + ((Math-num-integerp b) + (if (Math-zerop b) + (math-reject-arg a "*Division by zero") + (math-make-frac (cadr a) (math-mul (caddr a) (math-trunc b))))) + ((eq (car-safe b) 'frac) + (if (Math-zerop (cadr b)) + (math-reject-arg a "*Division by zero") + (math-make-frac (math-mul (cadr a) (caddr b)) (math-mul (caddr a) (cadr b))))) + (t (math-reject-arg b 'integerp)))) + (t + (math-reject-arg a 'integerp)))) (provide 'calc-frac) |