emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r103184: calc/calc-units.el (math-log


From: Jay Belanger
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r103184: calc/calc-units.el (math-logunits-quant): Add support for
Date: Mon, 07 Feb 2011 16:25:31 -0600
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 103184
committer: Jay Belanger <address@hidden>
branch nick: trunk
timestamp: Mon 2011-02-07 16:25:31 -0600
message:
  calc/calc-units.el (math-logunits-quant): Add support for
  non-logarithmic units.
modified:
  lisp/ChangeLog
  lisp/calc/calc-units.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2011-02-07 20:43:36 +0000
+++ b/lisp/ChangeLog    2011-02-07 22:25:31 +0000
@@ -1,3 +1,8 @@
+2011-02-07  Jay Belanger  <address@hidden>
+
+       * calc/calc-units.el (math-logunits-quant): Add support for
+       non-logarithmic units.
+
 2011-02-07  Ken Manheimer  <address@hidden>
 
        * allout.el (allout-after-copy-or-kill-hook): New hook for

=== modified file 'lisp/calc/calc-units.el'
--- a/lisp/calc/calc-units.el   2011-02-07 00:54:23 +0000
+++ b/lisp/calc/calc-units.el   2011-02-07 22:25:31 +0000
@@ -1737,26 +1737,28 @@
        (calc-binary-op "lu/" 'calcFunc-lupowerdiv arg)))))
 
 (defun math-logunits-quant (val ref power)
-  (let ((lunit (math-simplify (math-extract-logunits val))))
+  (let* ((units (math-simplify (math-extract-units val)))
+         (lunit (math-simplify (math-extract-logunits units))))
     (if (not (eq (car-safe lunit) 'var))
         (calc-record-why "*Improper logarithmic unit" lunit)
-      (if (not (eq 1 (math-simplify (math-extract-units (math-div val 
lunit)))))
-          (calc-record-why "*Inappropriate units" nil)
-        (let ((coeff (math-simplify (math-div val lunit))))
-          (if (equal lunit '(var dB var-dB))
-              (math-mul 
-               ref
-               (math-pow 
-                10
-                (math-div
-                 coeff
-                 (if power 10 20))))
-            (math-mul 
-             ref
-             (calcFunc-exp
-              (if power 
-                  (math-mul 2 coeff)
-                coeff)))))))))
+      (let ((runits (math-simplify (math-div units lunit)))
+            (coeff (math-simplify (math-div val units))))
+        (math-mul
+         (if (equal lunit '(var dB var-dB))
+             (math-mul 
+              ref
+              (math-pow 
+               10
+               (math-div
+                coeff
+                (if power 10 20))))
+           (math-mul 
+            ref
+            (calcFunc-exp
+             (if power 
+                 (math-mul 2 coeff)
+               coeff))))
+         runits)))))
 
 (defvar calc-logunits-field-reference)
 (defvar calc-logunits-power-reference)


reply via email to

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