]> git.eshelyaron.com Git - emacs.git/commitdiff
calc/calc-units.el (math-logunits-quant): Add support for
authorJay Belanger <jay.p.belanger@gmail.com>
Mon, 7 Feb 2011 22:25:31 +0000 (16:25 -0600)
committerJay Belanger <jay.p.belanger@gmail.com>
Mon, 7 Feb 2011 22:25:31 +0000 (16:25 -0600)
non-logarithmic units.

lisp/ChangeLog
lisp/calc/calc-units.el

index a55a656af80047367d1a1433d52cb36994945453..8826f8845602bfc246cd18c88add01502d8a544a 100644 (file)
@@ -1,3 +1,8 @@
+2011-02-07  Jay Belanger  <jay.p.belanger@gmail.com>
+
+       * calc/calc-units.el (math-logunits-quant): Add support for
+       non-logarithmic units.
+
 2011-02-07  Ken Manheimer  <ken.manheimer@gmail.com>
 
        * allout.el (allout-after-copy-or-kill-hook): New hook for
index 65b3356b13aa455d49e396914c64c040576c6b5c..569d5d3dc35379e9a63d524a6b33ea19c8e84da7 100644 (file)
@@ -1737,26 +1737,28 @@ If EXPR is nil, return nil."
        (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)