diff options
| author | Vincent Belaïche | 2010-04-06 20:33:00 -0500 |
|---|---|---|
| committer | Jay Belanger | 2010-04-06 20:33:00 -0500 |
| commit | 317a26be001283988504d544692930af75a92e53 (patch) | |
| tree | f9e071fe52d64ab3177ffef1c26c7448a7fdd6bc | |
| parent | cb1b04a5d87eb8e4e72dbcc99d8555992c7765dc (diff) | |
| download | emacs-317a26be001283988504d544692930af75a92e53.tar.gz emacs-317a26be001283988504d544692930af75a92e53.zip | |
(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 @@ | |||
| 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 | ||