Mercurial > emacs
comparison lisp/calc/calc-frac.el @ 107791:439c9c198a6b
(calcFunc-fdiv): Allow `fdiv' to divide fractions.
author | Jay Belanger <jay.p.belanger@gmail.com> |
---|---|
date | Tue, 06 Apr 2010 20:33:00 -0500 |
parents | 1d1d5d9bd884 |
children | 84df551e8c64 |
comparison
equal
deleted
inserted
replaced
107790:f56b90a69fac | 107791:439c9c198a6b |
---|---|
203 (setq temp (math-add (math-mul (car cf) n) d) | 203 (setq temp (math-add (math-mul (car cf) n) d) |
204 d n | 204 d n |
205 n temp)) | 205 n temp)) |
206 (math-div n d))) | 206 (math-div n d))) |
207 | 207 |
208 | |
209 | |
210 (defun calcFunc-fdiv (a b) ; [R I I] [Public] | 208 (defun calcFunc-fdiv (a b) ; [R I I] [Public] |
211 (if (Math-num-integerp a) | 209 (cond |
212 (if (Math-num-integerp b) | 210 ((Math-num-integerp a) |
213 (if (Math-zerop b) | 211 (cond |
214 (math-reject-arg a "*Division by zero") | 212 ((Math-num-integerp b) |
215 (math-make-frac (math-trunc a) (math-trunc b))) | 213 (if (Math-zerop b) |
216 (math-reject-arg b 'integerp)) | 214 (math-reject-arg a "*Division by zero") |
217 (math-reject-arg a 'integerp))) | 215 (math-make-frac (math-trunc a) (math-trunc b)))) |
216 ((eq (car-safe b) 'frac) | |
217 (if (Math-zerop (cadr b)) | |
218 (math-reject-arg a "*Division by zero") | |
219 (math-make-frac (math-mul (math-trunc a) (caddr b)) (cadr b)))) | |
220 (t (math-reject-arg b 'integerp)))) | |
221 ((eq (car-safe a) 'frac) | |
222 (cond | |
223 ((Math-num-integerp b) | |
224 (if (Math-zerop b) | |
225 (math-reject-arg a "*Division by zero") | |
226 (math-make-frac (cadr a) (math-mul (caddr a) (math-trunc b))))) | |
227 ((eq (car-safe b) 'frac) | |
228 (if (Math-zerop (cadr b)) | |
229 (math-reject-arg a "*Division by zero") | |
230 (math-make-frac (math-mul (cadr a) (caddr b)) (math-mul (caddr a) (cadr b))))) | |
231 (t (math-reject-arg b 'integerp)))) | |
232 (t | |
233 (math-reject-arg a 'integerp)))) | |
218 | 234 |
219 (provide 'calc-frac) | 235 (provide 'calc-frac) |
220 | 236 |
221 ;; arch-tag: 89d65274-0b3b-42d8-aacd-eaf86da5b4ea | 237 ;; arch-tag: 89d65274-0b3b-42d8-aacd-eaf86da5b4ea |
222 ;;; calc-frac.el ends here | 238 ;;; calc-frac.el ends here |