1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-26 07:33:47 +00:00

(calcFunc-fdiv): Allow `fdiv' to divide fractions.

This commit is contained in:
Vincent Belaïche 2010-04-06 20:33:00 -05:00 committed by Jay Belanger
parent cb1b04a5d8
commit 317a26be00

View File

@ -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)