diff options
author | Miles Bader <miles@gnu.org> | 2007-10-11 16:22:07 +0000 |
---|---|---|
committer | Miles Bader <miles@gnu.org> | 2007-10-11 16:22:07 +0000 |
commit | 90c1c829ff9f08fd7d872e0099b587268727a23f (patch) | |
tree | 36c685ef2aecf32203747dd40d7800aae78fba9f /lisp/calc | |
parent | 41520ab0b3f0a0ae6bd81731f67eb43cf23500d8 (diff) | |
parent | 39e55877e2bfca874f1640302fec16ded1bbf7d3 (diff) | |
download | emacs-90c1c829ff9f08fd7d872e0099b587268727a23f.tar.gz |
Merge from emacs--devo--0
Patches applied:
* emacs--devo--0 (patch 866-879)
- Merge multi-tty branch
- Update from CVS
- Merge from emacs--rel--22
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-257
Diffstat (limited to 'lisp/calc')
-rw-r--r-- | lisp/calc/calc-ext.el | 66 | ||||
-rw-r--r-- | lisp/calc/calc-help.el | 92 | ||||
-rw-r--r-- | lisp/calc/calc-math.el | 39 | ||||
-rw-r--r-- | lisp/calc/calc-misc.el | 6 | ||||
-rw-r--r-- | lisp/calc/calc-store.el | 32 | ||||
-rw-r--r-- | lisp/calc/calc-stuff.el | 2 | ||||
-rw-r--r-- | lisp/calc/calc-units.el | 44 | ||||
-rw-r--r-- | lisp/calc/calc.el | 288 |
8 files changed, 291 insertions, 278 deletions
diff --git a/lisp/calc/calc-ext.el b/lisp/calc/calc-ext.el index ab8f743eb34..0aa053702b8 100644 --- a/lisp/calc/calc-ext.el +++ b/lisp/calc/calc-ext.el @@ -618,15 +618,15 @@ (calc-init-prefixes) - (mapcar (function - (lambda (x) - (define-key calc-mode-map (format "c%c" x) 'calc-clean-num) - (define-key calc-mode-map (format "j%c" x) 'calc-select-part) - (define-key calc-mode-map (format "r%c" x) 'calc-recall-quick) - (define-key calc-mode-map (format "s%c" x) 'calc-store-quick) - (define-key calc-mode-map (format "t%c" x) 'calc-store-into-quick) - (define-key calc-mode-map (format "u%c" x) 'calc-quick-units))) - "0123456789") + (mapc (function + (lambda (x) + (define-key calc-mode-map (format "c%c" x) 'calc-clean-num) + (define-key calc-mode-map (format "j%c" x) 'calc-select-part) + (define-key calc-mode-map (format "r%c" x) 'calc-recall-quick) + (define-key calc-mode-map (format "s%c" x) 'calc-store-quick) + (define-key calc-mode-map (format "t%c" x) 'calc-store-into-quick) + (define-key calc-mode-map (format "u%c" x) 'calc-quick-units))) + "0123456789") (let ((i ?A)) (while (<= i ?z) @@ -635,7 +635,7 @@ (cons 'keymap (cons (cons ?\e (aref (nth 1 calc-mode-map) i)) (cdr (aref (nth 1 calc-mode-map) i)))))) (setq i (1+ i)))) - + (setq calc-alg-map (copy-keymap calc-mode-map) calc-alg-esc-map (copy-keymap esc-map)) (let ((i 32)) @@ -651,7 +651,7 @@ (define-key calc-alg-map "\e\177" 'calc-pop-above) ;;;; (Autoloads here) - (mapcar (function (lambda (x) + (mapc (function (lambda (x) (mapcar (function (lambda (func) (autoload func (car x)))) (cdr x)))) '( @@ -1021,7 +1021,7 @@ calc-arctan calc-arctan2 calc-arctanh calc-conj calc-cos calc-cosh calc-cot calc-coth calc-csc calc-csch calc-degrees-mode calc-exp calc-expm1 calc-hypot calc-ilog calc-imaginary calc-isqrt calc-ln calc-lnp1 calc-log calc-log10 -calc-pi calc-radians-mode calc-sec calc-sech +calc-pi calc-radians-mode calc-sec calc-sech calc-sin calc-sincos calc-sinh calc-sqrt calc-tan calc-tanh calc-to-degrees calc-to-radians) @@ -1277,7 +1277,7 @@ calc-kill calc-kill-region calc-yank)))) calc-redo-list nil) (let (calc-stack calc-user-parse-tables calc-standard-date-formats calc-invocation-macro) - (mapcar (function (lambda (v) (set v nil))) calc-local-var-list) + (mapc (function (lambda (v) (set v nil))) calc-local-var-list) (if (and arg (<= arg 0)) (calc-mode-var-list-restore-default-values) (calc-mode-var-list-restore-saved-values))) @@ -1357,7 +1357,7 @@ calc-kill calc-kill-region calc-yank)))) (with-current-buffer calc-main-buffer calc-hyperbolic-flag) calc-hyperbolic-flag)) - (msg (if hyp-flag + (msg (if hyp-flag "Inverse Hyperbolic..." "Inverse..."))) (calc-fancy-prefix 'calc-inverse-flag msg n))) @@ -1438,7 +1438,7 @@ calc-kill calc-kill-region calc-yank)))) (with-current-buffer calc-main-buffer calc-inverse-flag) calc-inverse-flag)) - (msg (if inv-flag + (msg (if inv-flag "Inverse Hyperbolic..." "Hyperbolic..."))) (calc-fancy-prefix 'calc-hyperbolic-flag msg n))) @@ -1849,7 +1849,7 @@ calc-kill calc-kill-region calc-yank)))) (setq calc-z-prefix-buf (concat (if (= flags 1) "SHIFT + " "") desc)) (if (> (+ (length calc-z-prefix-buf) (length desc)) 58) - (setq calc-z-prefix-msgs + (setq calc-z-prefix-msgs (cons calc-z-prefix-buf calc-z-prefix-msgs) calc-z-prefix-buf (concat (if (= flags 1) "SHIFT + " "") desc)) @@ -1879,14 +1879,14 @@ calc-kill calc-kill-region calc-yank)))) (last-val (intern (concat (symbol-name name) "-last")))) (list 'progn ; (list 'defvar cache-prec (if init (math-numdigs (nth 1 init)) -100)) - (list 'defvar cache-prec + (list 'defvar cache-prec `(cond ((consp ,init) (math-numdigs (nth 1 ,init))) - (,init + (,init (nth 1 (math-numdigs (eval ,init)))) (t -100))) - (list 'defvar cache-val + (list 'defvar cache-val `(cond ((consp ,init) ,init) (,init (eval ,init)) @@ -1963,7 +1963,7 @@ calc-kill calc-kill-region calc-yank)))) (defconst math-approx-sqrt-e (math-read-number-simple "1.648721270700128146849") "An approximation for sqrt(3).") - + (math-defcache math-sqrt-e math-approx-sqrt-e (math-add-float '(float 1 0) (math-exp-minus-1-raw '(float 5 -1)))) @@ -1975,11 +1975,11 @@ calc-kill calc-kill-region calc-yank)))) '(float 5 -1))) (defconst math-approx-gamma-const - (math-read-number-simple + (math-read-number-simple "0.5772156649015328606065120900824024310421593359399235988057672348848677267776646709369470632917467495") "An approximation for gamma.") -(math-defcache math-gamma-const nil +(math-defcache math-gamma-const nil math-approx-gamma-const) (defun math-half-circle (symb) @@ -2148,12 +2148,12 @@ calc-kill calc-kill-region calc-yank)))) (unless a (setq a 1)) (and - (not (memq nil (mapcar + (not (memq nil (mapcar (lambda (x) (eq x 0)) (nthcdr (1+ n) row)))) - (not (memq nil (mapcar + (not (memq nil (mapcar (lambda (x) (eq x 0)) - (butlast + (butlast (cdr row) (- (length row) n))))) (eq (elt row n) a))) @@ -2218,7 +2218,7 @@ If X is not an error form, return X." (if (eq (car-safe x) 'sdev) (nth 1 x) x)) - + (defun math-get-sdev (x &optional one) "Get the standard deviation of the error form X. If X is not an error form, return 1." @@ -2331,15 +2331,15 @@ If X is not an error form, return 1." (and (symbolp (car math-normalize-a)) (or (eq calc-simplify-mode 'none) (and (eq calc-simplify-mode 'num) - (let ((aptr (setq math-normalize-a + (let ((aptr (setq math-normalize-a (cons (car math-normalize-a) - (mapcar 'math-normalize + (mapcar 'math-normalize (cdr math-normalize-a)))))) (while (and aptr (math-constp (car aptr))) (setq aptr (cdr aptr))) aptr))) - (cons (car math-normalize-a) + (cons (car math-normalize-a) (mapcar 'math-normalize (cdr math-normalize-a)))))) @@ -2720,8 +2720,8 @@ If X is not an error form, return 1." (setq mmt-nextval (funcall math-mt-func mmt-expr)) (not (equal mmt-expr mmt-nextval))) (setq mmt-expr mmt-nextval - math-mt-many (if (> math-mt-many 0) - (1- math-mt-many) + math-mt-many (if (> math-mt-many 0) + (1- math-mt-many) (1+ math-mt-many)))) (if (or (Math-primp mmt-expr) (<= math-mt-many 0)) @@ -3046,10 +3046,10 @@ If X is not an error form, return 1." math-read-big-baseline math-read-big-h2 new-pos p) (while (setq new-pos (string-match "\n" str pos)) - (setq math-read-big-lines + (setq math-read-big-lines (cons (substring str pos new-pos) math-read-big-lines) pos (1+ new-pos))) - (setq math-read-big-lines + (setq math-read-big-lines (nreverse (cons (substring str pos) math-read-big-lines)) p math-read-big-lines) (while p diff --git a/lisp/calc/calc-help.el b/lisp/calc/calc-help.el index 871f281aa5e..ed1c93e8694 100644 --- a/lisp/calc/calc-help.el +++ b/lisp/calc/calc-help.el @@ -321,11 +321,11 @@ C-w Describe how there is no warranty for Calc." (defun calc-describe-function (&optional func) (interactive) (unless calc-help-function-list - (setq calc-help-function-list + (setq calc-help-function-list (calc-help-index-entries "Function" "Command"))) (or func (setq func (completing-read "Describe function: " - calc-help-function-list + calc-help-function-list nil t))) (if (string-match "\\`calc-." func) (calc-describe-thing func "Command Index") @@ -334,7 +334,7 @@ C-w Describe how there is no warranty for Calc." (defun calc-describe-variable (&optional var) (interactive) (unless calc-help-variable-list - (setq calc-help-variable-list + (setq calc-help-variable-list (calc-help-index-entries "Variable"))) (or var (setq var (completing-read "Describe variable: " @@ -419,49 +419,49 @@ C-w Describe how there is no warranty for Calc." (princ "Or type `h i' to read the full Calc manual on-line.\n\n") (princ "Basic keys:\n") (let* ((calc-full-help-flag t)) - (mapcar (function (lambda (x) (princ (format " %s\n" x)))) - (nreverse (cdr (reverse (cdr (calc-help)))))) - (mapcar (function (lambda (prefix) - (let ((msgs (condition-case err - (funcall prefix) - (error nil)))) - (if (car msgs) - (princ - (if (eq (nth 2 msgs) ?v) - "\n`v' or `V' prefix (vector/matrix) keys: \n" - (if (nth 2 msgs) - (format - "\n`%c' prefix (%s) keys:\n" - (nth 2 msgs) - (or (cdr (assq (nth 2 msgs) - calc-help-long-names)) - (nth 1 msgs))) - (format "\n%s-modified keys:\n" - (capitalize (nth 1 msgs))))))) - (mapcar (function (lambda (x) - (princ (format " %s\n" x)))) - (car msgs))))) - '(calc-inverse-prefix-help - calc-hyperbolic-prefix-help - calc-inv-hyp-prefix-help - calc-a-prefix-help - calc-b-prefix-help - calc-c-prefix-help - calc-d-prefix-help - calc-f-prefix-help - calc-g-prefix-help - calc-h-prefix-help - calc-j-prefix-help - calc-k-prefix-help - calc-m-prefix-help - calc-r-prefix-help - calc-s-prefix-help - calc-t-prefix-help - calc-u-prefix-help - calc-v-prefix-help - calc-shift-Y-prefix-help - calc-shift-Z-prefix-help - calc-z-prefix-help))) + (mapc (function (lambda (x) (princ (format " %s\n" x)))) + (nreverse (cdr (reverse (cdr (calc-help)))))) + (mapc (function (lambda (prefix) + (let ((msgs (condition-case err + (funcall prefix) + (error nil)))) + (if (car msgs) + (princ + (if (eq (nth 2 msgs) ?v) + "\n`v' or `V' prefix (vector/matrix) keys: \n" + (if (nth 2 msgs) + (format + "\n`%c' prefix (%s) keys:\n" + (nth 2 msgs) + (or (cdr (assq (nth 2 msgs) + calc-help-long-names)) + (nth 1 msgs))) + (format "\n%s-modified keys:\n" + (capitalize (nth 1 msgs))))))) + (mapcar (function (lambda (x) + (princ (format " %s\n" x)))) + (car msgs))))) + '(calc-inverse-prefix-help + calc-hyperbolic-prefix-help + calc-inv-hyp-prefix-help + calc-a-prefix-help + calc-b-prefix-help + calc-c-prefix-help + calc-d-prefix-help + calc-f-prefix-help + calc-g-prefix-help + calc-h-prefix-help + calc-j-prefix-help + calc-k-prefix-help + calc-m-prefix-help + calc-r-prefix-help + calc-s-prefix-help + calc-t-prefix-help + calc-u-prefix-help + calc-v-prefix-help + calc-shift-Y-prefix-help + calc-shift-Z-prefix-help + calc-z-prefix-help))) (print-help-return-message))) (defun calc-h-prefix-help () diff --git a/lisp/calc/calc-math.el b/lisp/calc/calc-math.el index 3e4743d58ae..3a2319e9a2c 100644 --- a/lisp/calc/calc-math.el +++ b/lisp/calc/calc-math.el @@ -53,28 +53,41 @@ ;;; is an Emacs float, for acceptable d.dddd.... (defvar math-largest-emacs-expt - (let ((x 1)) - (while (condition-case nil - (expt 10.0 x) - (error nil)) - (setq x (* 2 x))) - (setq x (/ x 2)) - (while (condition-case nil - (expt 10.0 x) - (error nil)) - (setq x (1+ x))) - (- x 2)) + (let ((x 1) + (pow 1e2)) + ;; The following loop is for efficiency; it should stop when + ;; 10^(2x) is too large. This could be indicated by a range + ;; error when computing 10^(2x) or an infinite value for 10^(2x). + (while (and + pow + (< pow 1.0e+INF)) + (setq x (* 2 x)) + (setq pow (condition-case nil + (expt 10.0 (* 2 x)) + (error nil)))) + ;; The following loop should stop when 10^(x+1) is too large. + (setq pow (condition-case nil + (expt 10.0 (1+ x)) + (error nil))) + (while (and + pow + (< pow 1.0e+INF)) + (setq x (1+ x)) + (setq pow (condition-case nil + (expt 10.0 (1+ x)) + (error nil)))) + (1- x)) "The largest exponent which Calc will convert to an Emacs float.") (defvar math-smallest-emacs-expt (let ((x -1)) (while (condition-case nil - (expt 10.0 x) + (> (expt 10.0 x) 0.0) (error nil)) (setq x (* 2 x))) (setq x (/ x 2)) (while (condition-case nil - (expt 10.0 x) + (> (expt 10.0 x) 0.0) (error nil)) (setq x (1- x))) (+ x 2)) diff --git a/lisp/calc/calc-misc.el b/lisp/calc/calc-misc.el index 10222fc1625..b660e046a21 100644 --- a/lisp/calc/calc-misc.el +++ b/lisp/calc/calc-misc.el @@ -145,9 +145,9 @@ Calc user interface as before (either C-x * C or C-x * K; initially C-x * C). "Create another, independent Calculator buffer." (interactive) (if (eq major-mode 'calc-mode) - (mapcar (function - (lambda (v) - (set-default v (symbol-value v)))) calc-local-var-list)) + (mapc (function + (lambda (v) + (set-default v (symbol-value v)))) calc-local-var-list)) (set-buffer (generate-new-buffer "*Calculator*")) (pop-to-buffer (current-buffer)) (calc-mode)) diff --git a/lisp/calc/calc-store.el b/lisp/calc/calc-store.el index 75a17661746..e439150814a 100644 --- a/lisp/calc/calc-store.el +++ b/lisp/calc/calc-store.el @@ -127,7 +127,7 @@ (cond ((and (memq var '(var-e var-i var-pi var-phi var-gamma)) (eq (car-safe old) 'special-const)) - (setq msg (format " (Note: Built-in definition of %s has been lost)" + (setq msg (format " (Note: Built-in definition of %s has been lost)" (calc-var-name var)))) ((and (memq var '(var-inf var-uinf var-nan)) (null old)) @@ -172,28 +172,28 @@ () (setq calc-var-name-map (copy-keymap minibuffer-local-completion-map)) (define-key calc-var-name-map " " 'self-insert-command) - (mapcar (function - (lambda (x) - (define-key calc-var-name-map (char-to-string x) - 'calcVar-digit))) - "0123456789") - (mapcar (function - (lambda (x) - (define-key calc-var-name-map (char-to-string x) - 'calcVar-oper))) - "+-*/^|")) + (mapc (function + (lambda (x) + (define-key calc-var-name-map (char-to-string x) + 'calcVar-digit))) + "0123456789") + (mapc (function + (lambda (x) + (define-key calc-var-name-map (char-to-string x) + 'calcVar-oper))) + "+-*/^|")) (defvar calc-store-opers) (defun calc-read-var-name (prompt &optional calc-store-opers) (setq calc-given-value nil calc-aborted-prefix nil) - (let ((var (concat + (let ((var (concat "var-" (let ((minibuffer-completion-table - (mapcar (lambda (x) (substring x 4)) + (mapcar (lambda (x) (substring x 4)) (all-completions "var-" obarray))) - (minibuffer-completion-predicate + (minibuffer-completion-predicate (lambda (x) (boundp (intern (concat "var-" x))))) (minibuffer-completion-confirm t)) (read-from-minibuffer prompt nil calc-var-name-map nil))))) @@ -401,7 +401,7 @@ (unless (string= sconst "") (let ((value (cdr (assoc sconst sc)))) (or var (setq var (calc-read-var-name - (format "Copy special constant %s, to: " + (format "Copy special constant %s, to: " sconst)))) (if var (let ((msg (calc-store-value var value ""))) @@ -417,7 +417,7 @@ (or value (error "No such variable: \"%s\"" (calc-var-name var1))) (or var2 (setq var2 (calc-read-var-name - (format "Copy variable: %s, to: " + (format "Copy variable: %s, to: " (calc-var-name var1))))) (if var2 (let ((msg (calc-store-value var2 value ""))) diff --git a/lisp/calc/calc-stuff.el b/lisp/calc/calc-stuff.el index a1f50816519..5dcc5365d10 100644 --- a/lisp/calc/calc-stuff.el +++ b/lisp/calc/calc-stuff.el @@ -191,7 +191,7 @@ With a prefix, push that prefix as a number onto the stack." math-eval-rules-cache-tag t math-format-date-cache nil math-holidays-cache-tag t) - (mapcar (function (lambda (x) (set x -100))) math-cache-list) + (mapc (function (lambda (x) (set x -100))) math-cache-list) (unless inhibit-msg (message "All internal calculator caches have been reset")))) diff --git a/lisp/calc/calc-units.el b/lisp/calc/calc-units.el index 3724490169a..839bac77581 100644 --- a/lisp/calc/calc-units.el +++ b/lisp/calc/calc-units.el @@ -54,7 +54,7 @@ ( ft "12 in" "Foot" ) ( yd "3 ft" "Yard" ) ( mi "5280 ft" "Mile" ) - ( au "149597870691. m" "Astronomical Unit" ) + ( au "149597870691. m" "Astronomical Unit" ) ;; (approx) NASA JPL (http://neo.jpl.nasa.gov/glossary/au.html) ( lyr "c yr" "Light Year" ) ( pc "3.0856775854e16 m" "Parsec" ) ;; (approx) ESUWM @@ -91,7 +91,7 @@ ( tbsp "3 tsp" "Tablespoon" ) ;; ESUWM defines a US gallon as 231 in^3. ;; That gives the following exact value for tsp. - ( tsp "492892159375*10^(-11) ml" "Teaspoon" ) + ( tsp "492892159375*10^(-11) ml" "Teaspoon" ) ( vol "tsp+tbsp+ozfl+cup+pt+qt+gal" "Gallons + ... + teaspoons" ) ( galC "galUK" "Canadian Gallon" ) ( galUK "454609*10^(-5) L" "UK Gallon" ) ;; NIST @@ -342,13 +342,13 @@ Entries are (SYMBOL EXPR DOC-STRING TEMP-TYPE BASE-UNITS).") If EXPR is nil, return nil." (if expr (let ((cexpr (math-compose-expr expr 0))) - (replace-regexp-in-string + (replace-regexp-in-string " / " "/" (if (stringp cexpr) cexpr (math-composition-to-string cexpr)))))) -(defvar math-default-units-table +(defvar math-default-units-table (make-hash-table :test 'equal) "A table storing previously converted units.") @@ -356,7 +356,7 @@ If EXPR is nil, return nil." "Get default units to use when converting the units in EXPR." (let* ((units (math-get-units expr)) (standard-units (math-get-standard-units expr)) - (default-units (gethash + (default-units (gethash standard-units math-default-units-table))) (if (equal units (car default-units)) @@ -403,7 +403,7 @@ If EXPR is nil, return nil." (setq expr (math-mul expr uold)))) (unless new-units (setq defunits (math-get-default-units expr)) - (setq new-units + (setq new-units (read-string (concat (if uoldname (concat "Old units: " @@ -412,11 +412,11 @@ If EXPR is nil, return nil." "New units") (if defunits (concat - " (default: " + " (default " defunits "): ") ": ")))) - + (if (and (string= new-units "") defunits) @@ -476,7 +476,7 @@ If EXPR is nil, return nil." (setq defunits (math-get-default-units expr)) (setq unew (or new-units (math-read-expr - (read-string + (read-string (concat (if uoldname (concat "Old temperature units: " @@ -484,7 +484,7 @@ If EXPR is nil, return nil." ", new units") "New temperature units") (if defunits - (concat " (default: " + (concat " (default " defunits "): ") ": ")))))) @@ -507,7 +507,7 @@ If EXPR is nil, return nil." (calc-enter-result 1 "rmun" (math-simplify-units (math-extract-units (calc-top-n 1)))))) -;; The variables calc-num-units and calc-den-units are local to +;; The variables calc-num-units and calc-den-units are local to ;; calc-explain-units, but are used by calc-explain-units-rec, ;; which is called by calc-explain-units. (defvar calc-num-units) @@ -752,7 +752,7 @@ If EXPR is nil, return nil." (list (cons (car x) 1)))))) combined-units)) (let ((math-units-table tab)) - (mapcar 'math-find-base-units tab)) + (mapc 'math-find-base-units tab)) (message "Building units table...done") (setq math-units-table tab)))) @@ -794,7 +794,7 @@ If EXPR is nil, return nil." (old (assq (car (car ulist)) math-fbu-base))) (if old (setcdr old (+ (cdr old) p)) - (setq math-fbu-base + (setq math-fbu-base (cons (cons (car (car ulist)) p) math-fbu-base)))) (setq ulist (cdr ulist))))) ((math-scalarp expr)) @@ -988,8 +988,8 @@ If EXPR is nil, return nil." (if (equal (nth 4 math-fcu-u) (nth 4 u2)) (cons expr pow)))))) -;; The variables math-cu-new-units and math-cu-pure are local to -;; math-convert-units, but are used by math-convert-units-rec, +;; The variables math-cu-new-units and math-cu-pure are local to +;; math-convert-units, but are used by math-convert-units-rec, ;; which is called by math-convert-units. (defvar math-cu-new-units) (defvar math-cu-pure) @@ -1001,7 +1001,7 @@ If EXPR is nil, return nil." (if (eq (car-safe (nth 1 unew)) '+) (setq math-cu-new-units (nth 1 unew))))) (math-with-extra-prec 2 - (let ((compat (and (not math-cu-pure) + (let ((compat (and (not math-cu-pure) (math-find-compatible-unit expr math-cu-new-units))) (math-cu-unit-list nil) (math-combining-units nil)) @@ -1028,7 +1028,7 @@ If EXPR is nil, return nil." (defun math-convert-units-rec (expr) (if (math-units-in-expr-p expr nil) - (math-apply-units (math-to-standard-units + (math-apply-units (math-to-standard-units (list '/ expr math-cu-new-units) nil) math-cu-new-units math-cu-unit-list math-cu-pure) (if (Math-primp expr) @@ -1093,7 +1093,7 @@ If EXPR is nil, return nil." (calc-record-why "*Inconsistent units" math-simplify-expr) math-simplify-expr) (list '* (math-add (math-remove-units (nth 1 math-simplify-expr)) - (if (eq (car math-simplify-expr) '-) + (if (eq (car math-simplify-expr) '-) (math-neg ratio) ratio)) units))))) @@ -1187,7 +1187,7 @@ If EXPR is nil, return nil." (math-simplify-units-divisor np (cdr (cdr math-simplify-expr))) (if (eq math-try-cancel-units 0) (let* ((math-simplifying-units nil) - (base (math-simplify + (base (math-simplify (math-to-standard-units math-simplify-expr nil)))) (if (Math-numberp base) (setq math-simplify-expr base)))) @@ -1243,11 +1243,11 @@ If EXPR is nil, return nil." (math-realp (nth 2 math-simplify-expr)) (if (memq (car-safe (nth 1 math-simplify-expr)) '(* /)) (list (car (nth 1 math-simplify-expr)) - (list '^ (nth 1 (nth 1 math-simplify-expr)) + (list '^ (nth 1 (nth 1 math-simplify-expr)) (nth 2 math-simplify-expr)) - (list '^ (nth 2 (nth 1 math-simplify-expr)) + (list '^ (nth 2 (nth 1 math-simplify-expr)) (nth 2 math-simplify-expr))) - (math-simplify-units-pow (nth 1 math-simplify-expr) + (math-simplify-units-pow (nth 1 math-simplify-expr) (nth 2 math-simplify-expr))))) (math-defsimplify calcFunc-sqrt diff --git a/lisp/calc/calc.el b/lisp/calc/calc.el index 8e416293a45..913b02e003f 100644 --- a/lisp/calc/calc.el +++ b/lisp/calc/calc.el @@ -213,7 +213,7 @@ :group 'applications) ;;;###autoload -(defcustom calc-settings-file +(defcustom calc-settings-file (convert-standard-filename "~/.calc.el") "*File in which to record permanent settings." :group 'calc @@ -233,10 +233,10 @@ (texinfo-mode . calc-normal-language)) "*Alist of major modes with appropriate Calc languages." :group 'calc - :type '(alist :key-type (symbol :tag "Major mode") + :type '(alist :key-type (symbol :tag "Major mode") :value-type (symbol :tag "Calc language"))) -(defcustom calc-embedded-announce-formula +(defcustom calc-embedded-announce-formula "%Embed\n\\(% .*\n\\)*" "*A regular expression which is sure to be followed by a calc-embedded formula." :group 'calc @@ -259,13 +259,13 @@ :type '(alist :key-type (symbol :tag "Major mode") :value-type (regexp :tag "Regexp to announce formula"))) -(defcustom calc-embedded-open-formula +(defcustom calc-embedded-open-formula "\\`\\|^\n\\|\\$\\$?\\|\\\\\\[\\|^\\\\begin[^{].*\n\\|^\\\\begin{.*[^x]}.*\n\\|^@.*\n\\|^\\.EQ.*\n\\|\\\\(\\|^%\n\\|^\\.\\\\\"\n" "*A regular expression for the opening delimiter of a formula used by calc-embedded." :group 'calc :type '(regexp)) -(defcustom calc-embedded-close-formula +(defcustom calc-embedded-close-formula "\\'\\|\n$\\|\\$\\$?\\|\\\\]\\|^\\\\end[^{].*\n\\|^\\\\end{.*[^x]}.*\n\\|^@.*\n\\|^\\.EN.*\n\\|\\\\)\\|\n%\n\\|^\\.\\\\\"\n" "*A regular expression for the closing delimiter of a formula used by calc-embedded." :group 'calc @@ -279,13 +279,13 @@ :value-type (list (regexp :tag "Opening formula delimiter") (regexp :tag "Closing formula delimiter")))) -(defcustom calc-embedded-open-word +(defcustom calc-embedded-open-word "^\\|[^-+0-9.eE]" "*A regular expression for the opening delimiter of a formula used by calc-embedded-word." :group 'calc :type '(regexp)) -(defcustom calc-embedded-close-word +(defcustom calc-embedded-close-word "$\\|[^-+0-9.eE]" "*A regular expression for the closing delimiter of a formula used by calc-embedded-word." :group 'calc @@ -299,7 +299,7 @@ :value-type (list (regexp :tag "Opening word delimiter") (regexp :tag "Closing word delimiter")))) -(defcustom calc-embedded-open-plain +(defcustom calc-embedded-open-plain "%%% " "*A string which is the opening delimiter for a \"plain\" formula. If calc-show-plain mode is enabled, this is inserted at the front of @@ -307,7 +307,7 @@ each formula." :group 'calc :type '(string)) -(defcustom calc-embedded-close-plain +(defcustom calc-embedded-close-plain " %%%\n" "*A string which is the closing delimiter for a \"plain\" formula. See calc-embedded-open-plain." @@ -332,13 +332,13 @@ See calc-embedded-open-plain." :value-type (list (string :tag "Opening \"plain\" delimiter") (string :tag "Closing \"plain\" delimiter")))) -(defcustom calc-embedded-open-new-formula +(defcustom calc-embedded-open-new-formula "\n\n" "*A string which is inserted at front of formula by calc-embedded-new-formula." :group 'calc :type '(string)) -(defcustom calc-embedded-close-new-formula +(defcustom calc-embedded-close-new-formula "\n\n" "*A string which is inserted at end of formula by calc-embedded-new-formula." :group 'calc @@ -352,14 +352,14 @@ See calc-embedded-open-plain." :value-type (list (string :tag "Opening new formula delimiter") (string :tag "Closing new formula delimiter")))) -(defcustom calc-embedded-open-mode +(defcustom calc-embedded-open-mode "% " "*A string which should precede calc-embedded mode annotations. This is not required to be present for user-written mode annotations." :group 'calc :type '(string)) -(defcustom calc-embedded-close-mode +(defcustom calc-embedded-close-mode "\n" "*A string which should follow calc-embedded mode annotations. This is not required to be present for user-written mode annotations." @@ -384,19 +384,19 @@ This is not required to be present for user-written mode annotations." :value-type (list (string :tag "Opening annotation delimiter") (string :tag "Closing annotation delimiter")))) -(defcustom calc-gnuplot-name +(defcustom calc-gnuplot-name "gnuplot" "*Name of GNUPLOT program, for calc-graph features." :group 'calc :type '(string)) -(defcustom calc-gnuplot-plot-command +(defcustom calc-gnuplot-plot-command nil "*Name of command for displaying GNUPLOT output; %s = file name to print." :group 'calc :type '(choice (string) (sexp))) -(defcustom calc-gnuplot-print-command +(defcustom calc-gnuplot-print-command "lp %s" "*Name of command for printing GNUPLOT output; %s = file name to print." :group 'calc @@ -520,7 +520,7 @@ This is used only when calc-group-digits mode is on.") (defcalcmodevar calc-point-char "." "The character (in the form of a string) to be used as a decimal point.") - + (defcalcmodevar calc-frac-format '(":" nil) "Format of displayed fractions; a string of one or two of \":\" or \"/\".") @@ -710,9 +710,9 @@ If nil, selections displayed but ignored.") "YYddd< hh:mm:ss>")) (defcalcmodevar calc-autorange-units nil) - + (defcalcmodevar calc-was-keypad-mode nil) - + (defcalcmodevar calc-full-mode nil) (defcalcmodevar calc-user-parse-tables nil) @@ -722,7 +722,7 @@ If nil, selections displayed but ignored.") (defcalcmodevar calc-gnuplot-default-output "STDOUT") (defcalcmodevar calc-gnuplot-print-device "postscript") - + (defcalcmodevar calc-gnuplot-print-output "auto") (defcalcmodevar calc-gnuplot-geometry nil) @@ -730,7 +730,7 @@ If nil, selections displayed but ignored.") (defcalcmodevar calc-graph-default-resolution 15) (defcalcmodevar calc-graph-default-resolution-3d 5) - + (defcalcmodevar calc-invocation-macro nil) (defcalcmodevar calc-show-banner t @@ -926,8 +926,8 @@ If nil, selections displayed but ignored.") (defvar var-gamma '(special-const (math-gamma-const))) (defvar var-Modes '(special-const (math-get-modes-vec))) -(mapcar (lambda (v) (or (boundp v) (set v nil))) - calc-local-var-list) +(mapc (lambda (v) (or (boundp v) (set v nil))) + calc-local-var-list) (defvar calc-mode-map (let ((map (make-keymap))) @@ -983,89 +983,89 @@ If nil, selections displayed but ignored.") (if (eq (aref cmap i) 'undefined) 'undefined 'calcDigit-nondigit)) (setq i (1+ i))))) - (mapcar (lambda (x) (define-key map (char-to-string x) 'calcDigit-key)) - "_0123456789.e+-:n#@oh'\"mspM") - (mapcar (lambda (x) (define-key map (char-to-string x) 'calcDigit-letter)) + (mapc (lambda (x) (define-key map (char-to-string x) 'calcDigit-key)) + "_0123456789.e+-:n#@oh'\"mspM") + (mapc (lambda (x) (define-key map (char-to-string x) 'calcDigit-letter)) "abcdfgijklqrtuvwxyzABCDEFGHIJKLNOPQRSTUVWXYZ") (define-key map "'" 'calcDigit-algebraic) (define-key map "`" 'calcDigit-edit) (define-key map "\C-g" 'abort-recursive-edit) map)) -(mapcar (lambda (x) - (condition-case err - (progn - (define-key calc-digit-map x 'calcDigit-backspace) - (define-key calc-mode-map x 'calc-pop) - (define-key calc-mode-map - (if (vectorp x) - (if calc-emacs-type-lucid - (if (= (length x) 1) - (vector (if (consp (aref x 0)) - (cons 'meta (aref x 0)) - (list 'meta (aref x 0)))) - "\e\C-d") - (vconcat "\e" x)) - (concat "\e" x)) - 'calc-pop-above)) - (error nil))) - (if calc-scan-for-dels - (append (where-is-internal 'delete-backward-char global-map) - (where-is-internal 'backward-delete-char global-map) - '("\C-d")) - '("\177" "\C-d"))) +(mapc (lambda (x) + (condition-case err + (progn + (define-key calc-digit-map x 'calcDigit-backspace) + (define-key calc-mode-map x 'calc-pop) + (define-key calc-mode-map + (if (vectorp x) + (if calc-emacs-type-lucid + (if (= (length x) 1) + (vector (if (consp (aref x 0)) + (cons 'meta (aref x 0)) + (list 'meta (aref x 0)))) + "\e\C-d") + (vconcat "\e" x)) + (concat "\e" x)) + 'calc-pop-above)) + (error nil))) + (if calc-scan-for-dels + (append (where-is-internal 'delete-backward-char global-map) + (where-is-internal 'backward-delete-char global-map) + '("\C-d")) + '("\177" "\C-d"))) (defvar calc-dispatch-map (let ((map (make-keymap))) - (mapcar (lambda (x) - (define-key map (char-to-string (car x)) (cdr x)) - (when (string-match "abcdefhijklnopqrstuwxyz" - (char-to-string (car x))) - (define-key map (char-to-string (- (car x) ?a -1)) (cdr x))) - (define-key map (format "\e%c" (car x)) (cdr x))) - '( ( ?a . calc-embedded-activate ) - ( ?b . calc-big-or-small ) - ( ?c . calc ) - ( ?d . calc-embedded-duplicate ) - ( ?e . calc-embedded ) - ( ?f . calc-embedded-new-formula ) - ( ?g . calc-grab-region ) - ( ?h . calc-dispatch-help ) - ( ?i . calc-info ) - ( ?j . calc-embedded-select ) - ( ?k . calc-keypad ) - ( ?l . calc-load-everything ) - ( ?m . read-kbd-macro ) - ( ?n . calc-embedded-next ) - ( ?o . calc-other-window ) - ( ?p . calc-embedded-previous ) - ( ?q . quick-calc ) - ( ?r . calc-grab-rectangle ) - ( ?s . calc-info-summary ) - ( ?t . calc-tutorial ) - ( ?u . calc-embedded-update-formula ) - ( ?w . calc-embedded-word ) - ( ?x . calc-quit ) - ( ?y . calc-copy-to-buffer ) - ( ?z . calc-user-invocation ) - ( ?\' . calc-embedded-new-formula ) - ( ?\` . calc-embedded-edit ) - ( ?: . calc-grab-sum-down ) - ( ?_ . calc-grab-sum-across ) - ( ?0 . calc-reset ) - ( ?? . calc-dispatch-help ) - ( ?# . calc-same-interface ) - ( ?& . calc-same-interface ) - ( ?\\ . calc-same-interface ) - ( ?= . calc-same-interface ) - ( ?* . calc-same-interface ) - ( ?/ . calc-same-interface ) - ( ?+ . calc-same-interface ) - ( ?- . calc-same-interface ) )) + (mapc (lambda (x) + (define-key map (char-to-string (car x)) (cdr x)) + (when (string-match "abcdefhijklnopqrstuwxyz" + (char-to-string (car x))) + (define-key map (char-to-string (- (car x) ?a -1)) (cdr x))) + (define-key map (format "\e%c" (car x)) (cdr x))) + '( ( ?a . calc-embedded-activate ) + ( ?b . calc-big-or-small ) + ( ?c . calc ) + ( ?d . calc-embedded-duplicate ) + ( ?e . calc-embedded ) + ( ?f . calc-embedded-new-formula ) + ( ?g . calc-grab-region ) + ( ?h . calc-dispatch-help ) + ( ?i . calc-info ) + ( ?j . calc-embedded-select ) + ( ?k . calc-keypad ) + ( ?l . calc-load-everything ) + ( ?m . read-kbd-macro ) + ( ?n . calc-embedded-next ) + ( ?o . calc-other-window ) + ( ?p . calc-embedded-previous ) + ( ?q . quick-calc ) + ( ?r . calc-grab-rectangle ) + ( ?s . calc-info-summary ) + ( ?t . calc-tutorial ) + ( ?u . calc-embedded-update-formula ) + ( ?w . calc-embedded-word ) + ( ?x . calc-quit ) + ( ?y . calc-copy-to-buffer ) + ( ?z . calc-user-invocation ) + ( ?\' . calc-embedded-new-formula ) + ( ?\` . calc-embedded-edit ) + ( ?: . calc-grab-sum-down ) + ( ?_ . calc-grab-sum-across ) + ( ?0 . calc-reset ) + ( ?? . calc-dispatch-help ) + ( ?# . calc-same-interface ) + ( ?& . calc-same-interface ) + ( ?\\ . calc-same-interface ) + ( ?= . calc-same-interface ) + ( ?* . calc-same-interface ) + ( ?/ . calc-same-interface ) + ( ?+ . calc-same-interface ) + ( ?- . calc-same-interface ) )) map)) ;;;; (Autoloads here) -(mapcar +(mapc (lambda (x) (dolist (func (cdr x)) (autoload func (car x)))) '( @@ -1077,7 +1077,7 @@ If nil, selections displayed but ignored.") ("calc-embed" calc-do-embedded-activate) - ("calc-misc" + ("calc-misc" calc-do-handle-whys calc-do-refresh calc-num-prefix-name calc-record-list calc-record-why calc-report-bug calc-roll-down-stack calc-roll-up-stack calc-temp-minibuffer-message calcFunc-floor @@ -1087,7 +1087,7 @@ If nil, selections displayed but ignored.") math-negp math-posp math-pow math-read-radix-digit math-reject-arg math-trunc math-zerop))) -(mapcar +(mapc (lambda (x) (dolist (cmd (cdr x)) (autoload cmd (car x) nil t))) '( @@ -1095,7 +1095,7 @@ If nil, selections displayed but ignored.") calcDigit-algebraic calcDigit-edit) ("calc-misc" another-calc calc-big-or-small calc-dispatch-help - calc-help calc-info calc-info-goto-node calc-info-summary calc-inv + calc-help calc-info calc-info-goto-node calc-info-summary calc-inv calc-last-args-stub calc-missing-key calc-mod calc-other-window calc-over calc-percent calc-pop-above calc-power calc-roll-down calc-roll-up @@ -1193,12 +1193,12 @@ Notations: 3.14e6 3.14 * 10^6 \\{calc-mode-map} " (interactive) - (mapcar (function - (lambda (v) (set-default v (symbol-value v)))) calc-local-var-list) + (mapc (function + (lambda (v) (set-default v (symbol-value v)))) calc-local-var-list) (kill-all-local-variables) (use-local-map (if (eq calc-algebraic-mode 'total) (progn (require 'calc-ext) calc-alg-map) calc-mode-map)) - (mapcar (function (lambda (v) (make-local-variable v))) calc-local-var-list) + (mapc (function (lambda (v) (make-local-variable v))) calc-local-var-list) (make-local-variable 'overlay-arrow-position) (make-local-variable 'overlay-arrow-string) (add-hook 'change-major-mode-hook 'font-lock-defontify nil t) @@ -1375,8 +1375,8 @@ commands given here will actually operate on the *Calculator* stack." (calc-create-buffer)) (run-hooks 'calc-end-hook) (setq calc-undo-list nil calc-redo-list nil) - (mapcar (function (lambda (v) (set-default v (symbol-value v)))) - calc-local-var-list) + (mapc (function (lambda (v) (set-default v (symbol-value v)))) + calc-local-var-list) (let ((buf (current-buffer)) (win (get-buffer-window (current-buffer))) (kbuf (get-buffer "*Calc Keypad*"))) @@ -2284,7 +2284,7 @@ See calc-keypad for details." -(defconst math-bignum-digit-length +(defconst math-bignum-digit-length (truncate (/ (log10 (/ most-positive-fixnum 2)) 2)) "The length of a \"digit\" in Calc bignums. If a big integer is of the form (bigpos N0 N1 ...), this is the @@ -2292,11 +2292,11 @@ length of the allowable Emacs integers N0, N1,... The value of 2*10^(2*MATH-BIGNUM-DIGIT-LENGTH) must be less than the largest Emacs integer.") -(defconst math-bignum-digit-size +(defconst math-bignum-digit-size (expt 10 math-bignum-digit-length) "An upper bound for the size of the \"digit\"s in Calc bignums.") -(defconst math-small-integer-size +(defconst math-small-integer-size (expt math-bignum-digit-size 2) "An upper bound for the size of \"small integer\"s in Calc.") @@ -2307,16 +2307,16 @@ largest Emacs integer.") ;;; following forms: ;;; ;;; integer An integer. For normalized numbers, this format -;;; is used only for +;;; is used only for ;;; negative math-small-integer-size + 1 to ;;; math-small-integer-size - 1 ;;; -;;; (bigpos N0 N1 N2 ...) A big positive integer, -;;; N0 + N1*math-bignum-digit-size +;;; (bigpos N0 N1 N2 ...) A big positive integer, +;;; N0 + N1*math-bignum-digit-size ;;; + N2*(math-bignum-digit-size)^2 ... -;;; (bigneg N0 N1 N2 ...) A big negative integer, +;;; (bigneg N0 N1 N2 ...) A big negative integer, ;;; - N0 - N1*math-bignum-digit-size ... -;;; Each digit N is in the range +;;; Each digit N is in the range ;;; 0 ... math-bignum-digit-size -1. ;;; Normalized, always at least three N present, ;;; and the most significant N is nonzero. @@ -2407,14 +2407,14 @@ largest Emacs integer.") (cond ((not (consp math-normalize-a)) (if (integerp math-normalize-a) - (if (or (>= math-normalize-a math-small-integer-size) + (if (or (>= math-normalize-a math-small-integer-size) (<= math-normalize-a (- math-small-integer-size))) (math-bignum math-normalize-a) math-normalize-a) math-normalize-a)) ((eq (car math-normalize-a) 'bigpos) (if (eq (nth (1- (length math-normalize-a)) math-normalize-a) 0) - (let* ((last (setq math-normalize-a + (let* ((last (setq math-normalize-a (copy-sequence math-normalize-a))) (digs math-normalize-a)) (while (setq digs (cdr digs)) (or (eq (car digs) 0) (setq last digs))) @@ -2422,14 +2422,14 @@ largest Emacs integer.") (if (cdr (cdr (cdr math-normalize-a))) math-normalize-a (cond - ((cdr (cdr math-normalize-a)) (+ (nth 1 math-normalize-a) - (* (nth 2 math-normalize-a) + ((cdr (cdr math-normalize-a)) (+ (nth 1 math-normalize-a) + (* (nth 2 math-normalize-a) math-bignum-digit-size))) ((cdr math-normalize-a) (nth 1 math-normalize-a)) (t 0)))) ((eq (car math-normalize-a) 'bigneg) (if (eq (nth (1- (length math-normalize-a)) math-normalize-a) 0) - (let* ((last (setq math-normalize-a (copy-sequence math-normalize-a))) + (let* ((last (setq math-normalize-a (copy-sequence math-normalize-a))) (digs math-normalize-a)) (while (setq digs (cdr digs)) (or (eq (car digs) 0) (setq last digs))) @@ -2437,21 +2437,21 @@ largest Emacs integer.") (if (cdr (cdr (cdr math-normalize-a))) math-normalize-a (cond - ((cdr (cdr math-normalize-a)) (- (+ (nth 1 math-normalize-a) - (* (nth 2 math-normalize-a) + ((cdr (cdr math-normalize-a)) (- (+ (nth 1 math-normalize-a) + (* (nth 2 math-normalize-a) math-bignum-digit-size)))) ((cdr math-normalize-a) (- (nth 1 math-normalize-a))) (t 0)))) ((eq (car math-normalize-a) 'float) - (math-make-float (math-normalize (nth 1 math-normalize-a)) + (math-make-float (math-normalize (nth 1 math-normalize-a)) (nth 2 math-normalize-a))) - ((or (memq (car math-normalize-a) + ((or (memq (car math-normalize-a) '(frac cplx polar hms date mod sdev intv vec var quote special-const calcFunc-if calcFunc-lambda calcFunc-quote calcFunc-condition calcFunc-evalto)) (integerp (car math-normalize-a)) - (and (consp (car math-normalize-a)) + (and (consp (car math-normalize-a)) (not (eq (car (car math-normalize-a)) 'lambda)))) (require 'calc-ext) (math-normalize-fancy math-normalize-a)) @@ -2461,7 +2461,7 @@ largest Emacs integer.") (math-normalize-nonstandard)) (let ((args (mapcar 'math-normalize (cdr math-normalize-a)))) (or (condition-case err - (let ((func + (let ((func (assq (car math-normalize-a) '( ( + . math-add ) ( - . math-sub ) ( * . math-mul ) @@ -2477,7 +2477,7 @@ largest Emacs integer.") (require 'calc-ext) (math-recompile-eval-rules))) (and (or math-eval-rules-cache-other - (assq (car math-normalize-a) + (assq (car math-normalize-a) math-eval-rules-cache)) (math-apply-rewrites (cons (car math-normalize-a) args) @@ -2496,12 +2496,12 @@ largest Emacs integer.") (cons (car math-normalize-a) args)) nil) (wrong-type-argument - (or calc-next-why + (or calc-next-why (calc-record-why "Wrong type of argument" (cons (car math-normalize-a) args))) nil) (args-out-of-range - (calc-record-why "*Argument out of range" + (calc-record-why "*Argument out of range" (cons (car math-normalize-a) args)) nil) (inexact-result @@ -2559,7 +2559,7 @@ largest Emacs integer.") (defun math-bignum-big (a) ; [L s] (if (= a 0) nil - (cons (% a math-bignum-digit-size) + (cons (% a math-bignum-digit-size) (math-bignum-big (/ a math-bignum-digit-size))))) @@ -2595,7 +2595,7 @@ largest Emacs integer.") (defun math-div10-bignum (a) ; [l l] (if (cdr a) - (cons (+ (/ (car a) 10) (* (% (nth 1 a) 10) + (cons (+ (/ (car a) 10) (* (% (nth 1 a) 10) (expt 10 (1- math-bignum-digit-length)))) (math-div10-bignum (cdr a))) (list (/ (car a) 10)))) @@ -2649,10 +2649,10 @@ largest Emacs integer.") (if (consp a) (cons (car a) (math-scale-left-bignum (cdr a) n)) (if (>= n math-bignum-digit-length) - (if (or (>= a math-bignum-digit-size) + (if (or (>= a math-bignum-digit-size) (<= a (- math-bignum-digit-size))) (math-scale-left (math-bignum a) n) - (math-scale-left (* a math-bignum-digit-size) + (math-scale-left (* a math-bignum-digit-size) (- n math-bignum-digit-length))) (let ((sz (expt 10 (- (* 2 math-bignum-digit-length) n)))) (if (or (>= a sz) (<= a (- sz))) @@ -2662,7 +2662,7 @@ largest Emacs integer.") (defun math-scale-left-bignum (a n) (if (>= n math-bignum-digit-length) (while (>= (setq a (cons 0 a) - n (- n math-bignum-digit-length)) + n (- n math-bignum-digit-length)) math-bignum-digit-length))) (if (> n 0) (math-mul-bignum-digit a (expt 10 n) 0) @@ -2679,7 +2679,7 @@ largest Emacs integer.") (- (math-scale-right (- a) n))) (if (>= n math-bignum-digit-length) (while (and (> (setq a (/ a math-bignum-digit-size)) 0) - (>= (setq n (- n math-bignum-digit-length)) + (>= (setq n (- n math-bignum-digit-length)) math-bignum-digit-length)))) (if (> n 0) (/ a (expt 10 n)) @@ -2701,12 +2701,12 @@ largest Emacs integer.") (math-normalize (cons (car a) (let ((val (if (< n (- math-bignum-digit-length)) - (math-scale-right-bignum - (cdr a) + (math-scale-right-bignum + (cdr a) (- (- math-bignum-digit-length) n)) (if (< n 0) - (math-mul-bignum-digit - (cdr a) + (math-mul-bignum-digit + (cdr a) (expt 10 (+ math-bignum-digit-length n)) 0) (cdr a))))) ; n = -math-bignum-digit-length (if (and val (>= (car val) (/ math-bignum-digit-size 2))) @@ -2779,7 +2779,7 @@ largest Emacs integer.") (let* ((a (copy-sequence a)) (aa a) (carry nil) sum) (while (and aa b) (if carry - (if (< (setq sum (+ (car aa) (car b))) + (if (< (setq sum (+ (car aa) (car b))) (1- math-bignum-digit-size)) (progn (setcar aa (1+ sum)) @@ -2895,7 +2895,7 @@ largest Emacs integer.") (defun math-mul (a b) (or (and (not (consp a)) (not (consp b)) - (< a math-bignum-digit-size) (> a (- math-bignum-digit-size)) + (< a math-bignum-digit-size) (> a (- math-bignum-digit-size)) (< b math-bignum-digit-size) (> b (- math-bignum-digit-size)) (* a b)) (and (Math-zerop a) (not (eq (car-safe b) 'mod)) @@ -2982,8 +2982,8 @@ largest Emacs integer.") (and (= d 1) a) (let* ((a (copy-sequence a)) (aa a) prod) (while (progn - (setcar aa - (% (setq prod (+ (* (car aa) d) c)) + (setcar aa + (% (setq prod (+ (* (car aa) d) c)) math-bignum-digit-size)) (cdr aa)) (setq aa (cdr aa) @@ -3076,7 +3076,7 @@ largest Emacs integer.") (cdr res2))))) (defun math-div-bignum-part (a b blen) ; a < b*math-bignum-digit-size [D.l l L] - (let* ((num (+ (* (or (nth blen a) 0) math-bignum-digit-size) + (let* ((num (+ (* (or (nth blen a) 0) math-bignum-digit-size) (or (nth (1- blen) a) 0))) (den (nth (1- blen) b)) (guess (min (/ num den) (1- math-bignum-digit-size)))) @@ -3390,14 +3390,14 @@ largest Emacs integer.") (if a (let ((s "")) (while (cdr (cdr a)) - (setq s (concat - (format - (concat "%0" - (number-to-string (* 2 math-bignum-digit-length)) + (setq s (concat + (format + (concat "%0" + (number-to-string (* 2 math-bignum-digit-length)) "d") (+ (* (nth 1 a) math-bignum-digit-size) (car a))) s) a (cdr (cdr a)))) - (concat (int-to-string + (concat (int-to-string (+ (* (or (nth 1 a) 0) math-bignum-digit-size) (car a))) s)) "0")) |