emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r99838: (calcFunc-fdiv): Allow `fdiv'


From: Jay Belanger
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r99838: (calcFunc-fdiv): Allow `fdiv' to divide fractions.
Date: Tue, 06 Apr 2010 20:33:00 -0500
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 99838
author: Vincent Belaïche  <address@hidden>
committer: Jay Belanger <address@hidden>
branch nick: trunk
timestamp: Tue 2010-04-06 20:33:00 -0500
message:
  (calcFunc-fdiv): Allow `fdiv' to divide fractions.
modified:
  lisp/calc/calc-frac.el
=== modified file 'lisp/calc/calc-frac.el'
--- a/lisp/calc/calc-frac.el    2010-01-13 08:35:10 +0000
+++ b/lisp/calc/calc-frac.el    2010-04-07 01:33:00 +0000
@@ -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)
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]