Mercurial > emacs
comparison lisp/calc/calc-units.el @ 90201:fbb2bea03df9
Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-69
Merge from emacs--cvs-trunk--0
Patches applied:
* emacs--cvs-trunk--0 (patch 474-484)
- Update from CVS
- Merge from gnus--rel--5.10
* gnus--rel--5.10 (patch 88-91)
- Merge from emacs--cvs-trunk--0
- Update FSF's address in GPL notices
- Update from CVS
author | Miles Bader <miles@gnu.org> |
---|---|
date | Thu, 14 Jul 2005 08:02:00 +0000 |
parents | 5b029ff3b08d f3c30d255a4d |
children | 187d6a1f84f7 |
comparison
equal
deleted
inserted
replaced
90200:f9a65d7ebd29 | 90201:fbb2bea03df9 |
---|---|
808 expr | 808 expr |
809 (cons (car expr) | 809 (cons (car expr) |
810 (mapcar 'math-to-standard-rec (cdr expr)))))) | 810 (mapcar 'math-to-standard-rec (cdr expr)))))) |
811 | 811 |
812 (defun math-apply-units (expr units ulist &optional pure) | 812 (defun math-apply-units (expr units ulist &optional pure) |
813 (setq expr (math-simplify-units expr)) | |
813 (if ulist | 814 (if ulist |
814 (let ((new 0) | 815 (let ((new 0) |
815 value) | 816 value) |
816 (setq expr (math-simplify-units expr)) | |
817 (or (math-numberp expr) | 817 (or (math-numberp expr) |
818 (error "Incompatible units")) | 818 (error "Incompatible units")) |
819 (while (cdr ulist) | 819 (while (cdr ulist) |
820 (setq value (math-div expr (nth 1 (car ulist))) | 820 (setq value (math-div expr (nth 1 (car ulist))) |
821 value (math-floor (let ((calc-internal-prec | 821 value (math-floor (let ((calc-internal-prec |
824 new (math-add new (math-mul value (car (car ulist)))) | 824 new (math-add new (math-mul value (car (car ulist)))) |
825 expr (math-sub expr (math-mul value (nth 1 (car ulist)))) | 825 expr (math-sub expr (math-mul value (nth 1 (car ulist)))) |
826 ulist (cdr ulist))) | 826 ulist (cdr ulist))) |
827 (math-add new (math-mul (math-div expr (nth 1 (car ulist))) | 827 (math-add new (math-mul (math-div expr (nth 1 (car ulist))) |
828 (car (car ulist))))) | 828 (car (car ulist))))) |
829 (math-simplify-units (if pure | 829 (if pure |
830 expr | 830 expr |
831 (list '* expr units))))) | 831 (math-simplify-units (list '* expr units))))) |
832 | 832 |
833 (defvar math-decompose-units-cache nil) | 833 (defvar math-decompose-units-cache nil) |
834 (defun math-decompose-units (units) | 834 (defun math-decompose-units (units) |
835 (let ((u (math-check-unit-name units))) | 835 (let ((u (math-check-unit-name units))) |
836 (and u (eq (car-safe (nth 1 u)) '+) | 836 (and u (eq (car-safe (nth 1 u)) '+) |