Mercurial > emacs
annotate lisp/calc/calc-macs.el @ 45408:3e68a6534915
* minibuf.c (Fread_command, Fread_variable): Use SYMBOL_NAME and
assignment instead of XSYMBOL and name field and XSETSTRING.
author | Ken Raeburn <raeburn@raeburn.org> |
---|---|
date | Mon, 20 May 2002 08:06:21 +0000 |
parents | b7527fba7b15 |
children | f4d68f97221e |
rev | line source |
---|---|
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1 ;;; calc-macs.el --- important macros for Calc |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
2 |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40910
diff
changeset
|
3 ;; Copyright (C) 1990, 1991, 1992, 1993, 2001 Free Software Foundation, Inc. |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
4 |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
5 ;; Author: David Gillespie <daveg@synaptics.com> |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
6 ;; Maintainer: Colin Walters <walters@debian.org> |
40785 | 7 |
8 ;; This file is part of GNU Emacs. | |
9 | |
10 ;; GNU Emacs is distributed in the hope that it will be useful, | |
11 ;; but WITHOUT ANY WARRANTY. No author or distributor | |
12 ;; accepts responsibility to anyone for the consequences of using it | |
13 ;; or for whether it serves any particular purpose or works at all, | |
14 ;; unless he says so in writing. Refer to the GNU Emacs General Public | |
15 ;; License for full details. | |
16 | |
17 ;; Everyone is granted permission to copy, modify and redistribute | |
18 ;; GNU Emacs, but only under the conditions described in the | |
19 ;; GNU Emacs General Public License. A copy of this license is | |
20 ;; supposed to have been given to you along with GNU Emacs so you | |
21 ;; can know your rights and responsibilities. It should be in a | |
22 ;; file named COPYING. Among other things, the copyright notice | |
23 ;; and this notice must be preserved on all copies. | |
24 | |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
25 ;;; Commentary: |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
26 |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
27 ;;; Code: |
40785 | 28 |
29 (provide 'calc-macs) | |
30 | |
31 (defun calc-need-macros () nil) | |
32 | |
33 (defmacro calc-wrapper (&rest body) | |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
34 `(calc-do (function (lambda () |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
35 ,@body)))) |
40785 | 36 |
37 (defmacro calc-slow-wrapper (&rest body) | |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
38 `(calc-do |
41341
6ab668229754
(calc-slow-wrapper): Move (point) call outside of (function ...)
Colin Walters <walters@gnu.org>
parents:
41266
diff
changeset
|
39 (function (lambda () ,@body)) (point))) |
40785 | 40 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
41 (defmacro math-showing-full-precision (form) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
42 `(let ((calc-float-format calc-full-float-format)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
43 ,form)) |
40785 | 44 |
45 (defmacro math-with-extra-prec (delta &rest body) | |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
46 `(math-normalize |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
47 (let ((calc-internal-prec (+ calc-internal-prec ,delta))) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
48 ,@body))) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
49 |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
50 (defmacro math-working (msg arg) ; [Public] |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
51 `(if (eq calc-display-working-message 'lots) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
52 (math-do-working ,msg ,arg))) |
40785 | 53 |
43402
b7527fba7b15
(calc-with-default-simplification): Use &rest for body.
Colin Walters <walters@gnu.org>
parents:
41385
diff
changeset
|
54 (defmacro calc-with-default-simplification (&rest body) |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
55 `(let ((calc-simplify-mode (and (not (memq calc-simplify-mode '(none num))) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
56 calc-simplify-mode))) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
57 ,@body)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
58 |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
59 (defmacro calc-with-trail-buffer (&rest body) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
60 `(let ((save-buf (current-buffer)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
61 (calc-command-flags nil)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
62 (with-current-buffer (calc-trail-display t) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
63 (progn |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
64 (goto-char calc-trail-pointer) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
65 ,@body)))) |
40785 | 66 |
67 ;;; Faster in-line version zerop, normalized values only. | |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
68 (defsubst Math-zerop (a) ; [P N] |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
69 (if (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
70 (and (not (memq (car a) '(bigpos bigneg))) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
71 (if (eq (car a) 'float) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
72 (eq (nth 1 a) 0) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
73 (math-zerop a))) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
74 (eq a 0))) |
40785 | 75 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
76 (defsubst Math-integer-negp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
77 (if (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
78 (eq (car a) 'bigneg) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
79 (< a 0))) |
40785 | 80 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
81 (defsubst Math-integer-posp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
82 (if (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
83 (eq (car a) 'bigpos) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
84 (> a 0))) |
40785 | 85 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
86 (defsubst Math-negp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
87 (if (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
88 (or (eq (car a) 'bigneg) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
89 (and (not (eq (car a) 'bigpos)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
90 (if (memq (car a) '(frac float)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
91 (Math-integer-negp (nth 1 a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
92 (math-negp a)))) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
93 (< a 0))) |
40785 | 94 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
95 (defsubst Math-looks-negp (a) ; [P x] [Public] |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
96 (or (Math-negp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
97 (and (consp a) (or (eq (car a) 'neg) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
98 (and (memq (car a) '(* /)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
99 (or (math-looks-negp (nth 1 a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
100 (math-looks-negp (nth 2 a)))))))) |
40785 | 101 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
102 (defsubst Math-posp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
103 (if (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
104 (or (eq (car a) 'bigpos) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
105 (and (not (eq (car a) 'bigneg)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
106 (if (memq (car a) '(frac float)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
107 (Math-integer-posp (nth 1 a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
108 (math-posp a)))) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
109 (> a 0))) |
40785 | 110 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
111 (defsubst Math-integerp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
112 (or (not (consp a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
113 (memq (car a) '(bigpos bigneg)))) |
40785 | 114 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
115 (defsubst Math-natnump (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
116 (if (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
117 (eq (car a) 'bigpos) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
118 (>= a 0))) |
40785 | 119 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
120 (defsubst Math-ratp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
121 (or (not (consp a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
122 (memq (car a) '(bigpos bigneg frac)))) |
40785 | 123 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
124 (defsubst Math-realp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
125 (or (not (consp a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
126 (memq (car a) '(bigpos bigneg frac float)))) |
40785 | 127 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
128 (defsubst Math-anglep (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
129 (or (not (consp a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
130 (memq (car a) '(bigpos bigneg frac float hms)))) |
40785 | 131 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
132 (defsubst Math-numberp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
133 (or (not (consp a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
134 (memq (car a) '(bigpos bigneg frac float cplx polar)))) |
40785 | 135 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
136 (defsubst Math-scalarp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
137 (or (not (consp a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
138 (memq (car a) '(bigpos bigneg frac float cplx polar hms)))) |
40785 | 139 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
140 (defsubst Math-vectorp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
141 (and (consp a) (eq (car a) 'vec))) |
40785 | 142 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
143 (defsubst Math-messy-integerp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
144 (and (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
145 (eq (car a) 'float) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
146 (>= (nth 2 a) 0))) |
40785 | 147 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
148 (defsubst Math-objectp (a) ; [Public] |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
149 (or (not (consp a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
150 (memq (car a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
151 '(bigpos bigneg frac float cplx polar hms date sdev intv mod)))) |
40785 | 152 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
153 (defsubst Math-objvecp (a) ; [Public] |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
154 (or (not (consp a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
155 (memq (car a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
156 '(bigpos bigneg frac float cplx polar hms date |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
157 sdev intv mod vec)))) |
40785 | 158 |
159 ;;; Compute the negative of A. [O O; o o] [Public] | |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
160 (defsubst Math-integer-neg (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
161 (if (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
162 (if (eq (car a) 'bigpos) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
163 (cons 'bigneg (cdr a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
164 (cons 'bigpos (cdr a))) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
165 (- a))) |
40785 | 166 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
167 (defsubst Math-equal (a b) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
168 (= (math-compare a b) 0)) |
40785 | 169 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
170 (defsubst Math-lessp (a b) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
171 (= (math-compare a b) -1)) |
40785 | 172 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
173 (defsubst Math-primp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
174 (or (not (consp a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
175 (memq (car a) '(bigpos bigneg frac float cplx polar |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
176 hms date mod var)))) |
40785 | 177 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
178 (defsubst Math-num-integerp (a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
179 (or (not (consp a)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
180 (memq (car a) '(bigpos bigneg)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
181 (and (eq (car a) 'float) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
182 (>= (nth 2 a) 0)))) |
40785 | 183 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
184 (defsubst Math-bignum-test (a) ; [B N; B s; b b] |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
185 (if (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
186 a |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
187 (math-bignum a))) |
40785 | 188 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
189 (defsubst Math-equal-int (a b) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
190 (or (eq a b) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
191 (and (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
192 (eq (car a) 'float) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
193 (eq (nth 1 a) b) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
194 (= (nth 2 a) 0)))) |
40785 | 195 |
41266
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
196 (defsubst Math-natnum-lessp (a b) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
197 (if (consp a) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
198 (and (consp b) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
199 (= (math-compare-bignum (cdr a) (cdr b)) -1)) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
200 (or (consp b) |
c08a55ae8e5d
(calc-wrapper, calc-slow-wrapper)
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
201 (< a b)))) |
40785 | 202 |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40910
diff
changeset
|
203 ;;; calc-macs.el ends here |