aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Walters2001-11-14 09:01:51 +0000
committerColin Walters2001-11-14 09:01:51 +0000
commit7d70a3ba4e9fb49e592b3399a116363ccfa0e9e6 (patch)
treef1d79212b8e5a0b4830b6affae947f0528949279
parent898ea5c0b23ce37cc76a976c6bd5c27921308eeb (diff)
downloademacs-7d70a3ba4e9fb49e592b3399a116363ccfa0e9e6.tar.gz
emacs-7d70a3ba4e9fb49e592b3399a116363ccfa0e9e6.zip
(calcFunc-clip): Use `defalias' instead of `fset' and
`symbol-function'. Style cleanup; don't put closing parens on their own line, add "foo.el ends here" to each file, and update copyright date.
-rw-r--r--lisp/calc/calc-bin.el164
1 files changed, 57 insertions, 107 deletions
diff --git a/lisp/calc/calc-bin.el b/lisp/calc/calc-bin.el
index 23c682a0da1..3d153049975 100644
--- a/lisp/calc/calc-bin.el
+++ b/lisp/calc/calc-bin.el
@@ -1,5 +1,5 @@
1;; Calculator for GNU Emacs, part II [calc-bin.el] 1;; Calculator for GNU Emacs, part II [calc-bin.el]
2;; Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc. 2;; Copyright (C) 1990, 1991, 1992, 1993, 2001 Free Software Foundation, Inc.
3;; Written by Dave Gillespie, daveg@synaptics.com. 3;; Written by Dave Gillespie, daveg@synaptics.com.
4 4
5;; This file is part of GNU Emacs. 5;; This file is part of GNU Emacs.
@@ -37,8 +37,7 @@
37 (calc-enter-result 2 "and" 37 (calc-enter-result 2 "and"
38 (append '(calcFunc-and) 38 (append '(calcFunc-and)
39 (calc-top-list-n 2) 39 (calc-top-list-n 2)
40 (and n (list (prefix-numeric-value n)))))) 40 (and n (list (prefix-numeric-value n)))))))
41)
42 41
43(defun calc-or (n) 42(defun calc-or (n)
44 (interactive "P") 43 (interactive "P")
@@ -46,8 +45,7 @@
46 (calc-enter-result 2 "or" 45 (calc-enter-result 2 "or"
47 (append '(calcFunc-or) 46 (append '(calcFunc-or)
48 (calc-top-list-n 2) 47 (calc-top-list-n 2)
49 (and n (list (prefix-numeric-value n)))))) 48 (and n (list (prefix-numeric-value n)))))))
50)
51 49
52(defun calc-xor (n) 50(defun calc-xor (n)
53 (interactive "P") 51 (interactive "P")
@@ -55,8 +53,7 @@
55 (calc-enter-result 2 "xor" 53 (calc-enter-result 2 "xor"
56 (append '(calcFunc-xor) 54 (append '(calcFunc-xor)
57 (calc-top-list-n 2) 55 (calc-top-list-n 2)
58 (and n (list (prefix-numeric-value n)))))) 56 (and n (list (prefix-numeric-value n)))))))
59)
60 57
61(defun calc-diff (n) 58(defun calc-diff (n)
62 (interactive "P") 59 (interactive "P")
@@ -64,8 +61,7 @@
64 (calc-enter-result 2 "diff" 61 (calc-enter-result 2 "diff"
65 (append '(calcFunc-diff) 62 (append '(calcFunc-diff)
66 (calc-top-list-n 2) 63 (calc-top-list-n 2)
67 (and n (list (prefix-numeric-value n)))))) 64 (and n (list (prefix-numeric-value n)))))))
68)
69 65
70(defun calc-not (n) 66(defun calc-not (n)
71 (interactive "P") 67 (interactive "P")
@@ -73,8 +69,7 @@
73 (calc-enter-result 1 "not" 69 (calc-enter-result 1 "not"
74 (append '(calcFunc-not) 70 (append '(calcFunc-not)
75 (calc-top-list-n 1) 71 (calc-top-list-n 1)
76 (and n (list (prefix-numeric-value n)))))) 72 (and n (list (prefix-numeric-value n)))))))
77)
78 73
79(defun calc-lshift-binary (n) 74(defun calc-lshift-binary (n)
80 (interactive "P") 75 (interactive "P")
@@ -83,8 +78,7 @@
83 (calc-enter-result hyp "lsh" 78 (calc-enter-result hyp "lsh"
84 (append '(calcFunc-lsh) 79 (append '(calcFunc-lsh)
85 (calc-top-list-n hyp) 80 (calc-top-list-n hyp)
86 (and n (list (prefix-numeric-value n))))))) 81 (and n (list (prefix-numeric-value n))))))))
87)
88 82
89(defun calc-rshift-binary (n) 83(defun calc-rshift-binary (n)
90 (interactive "P") 84 (interactive "P")
@@ -93,8 +87,7 @@
93 (calc-enter-result hyp "rsh" 87 (calc-enter-result hyp "rsh"
94 (append '(calcFunc-rsh) 88 (append '(calcFunc-rsh)
95 (calc-top-list-n hyp) 89 (calc-top-list-n hyp)
96 (and n (list (prefix-numeric-value n))))))) 90 (and n (list (prefix-numeric-value n))))))))
97)
98 91
99(defun calc-lshift-arith (n) 92(defun calc-lshift-arith (n)
100 (interactive "P") 93 (interactive "P")
@@ -103,8 +96,7 @@
103 (calc-enter-result hyp "ash" 96 (calc-enter-result hyp "ash"
104 (append '(calcFunc-ash) 97 (append '(calcFunc-ash)
105 (calc-top-list-n hyp) 98 (calc-top-list-n hyp)
106 (and n (list (prefix-numeric-value n))))))) 99 (and n (list (prefix-numeric-value n))))))))
107)
108 100
109(defun calc-rshift-arith (n) 101(defun calc-rshift-arith (n)
110 (interactive "P") 102 (interactive "P")
@@ -113,8 +105,7 @@
113 (calc-enter-result hyp "rash" 105 (calc-enter-result hyp "rash"
114 (append '(calcFunc-rash) 106 (append '(calcFunc-rash)
115 (calc-top-list-n hyp) 107 (calc-top-list-n hyp)
116 (and n (list (prefix-numeric-value n))))))) 108 (and n (list (prefix-numeric-value n))))))))
117)
118 109
119(defun calc-rotate-binary (n) 110(defun calc-rotate-binary (n)
120 (interactive "P") 111 (interactive "P")
@@ -123,8 +114,7 @@
123 (calc-enter-result hyp "rot" 114 (calc-enter-result hyp "rot"
124 (append '(calcFunc-rot) 115 (append '(calcFunc-rot)
125 (calc-top-list-n hyp) 116 (calc-top-list-n hyp)
126 (and n (list (prefix-numeric-value n))))))) 117 (and n (list (prefix-numeric-value n))))))))
127)
128 118
129(defun calc-clip (n) 119(defun calc-clip (n)
130 (interactive "P") 120 (interactive "P")
@@ -132,8 +122,7 @@
132 (calc-enter-result 1 "clip" 122 (calc-enter-result 1 "clip"
133 (append '(calcFunc-clip) 123 (append '(calcFunc-clip)
134 (calc-top-list-n 1) 124 (calc-top-list-n 1)
135 (and n (list (prefix-numeric-value n)))))) 125 (and n (list (prefix-numeric-value n)))))))
136)
137 126
138(defun calc-word-size (n) 127(defun calc-word-size (n)
139 (interactive "P") 128 (interactive "P")
@@ -155,8 +144,7 @@
155 calc-leading-zeros))) 144 calc-leading-zeros)))
156 (if (< n 0) 145 (if (< n 0)
157 (message "Binary word size is %d bits (2's complement)." (- n)) 146 (message "Binary word size is %d bits (2's complement)." (- n))
158 (message "Binary word size is %d bits." n))) 147 (message "Binary word size is %d bits." n))))
159)
160 148
161 149
162 150
@@ -173,28 +161,23 @@
173 ;; also change global value so minibuffer sees it 161 ;; also change global value so minibuffer sees it
174 (setq-default calc-number-radix calc-number-radix)) 162 (setq-default calc-number-radix calc-number-radix))
175 (setq n calc-number-radix)) 163 (setq n calc-number-radix))
176 (message "Number radix is %d." n)) 164 (message "Number radix is %d." n)))
177)
178 165
179(defun calc-decimal-radix () 166(defun calc-decimal-radix ()
180 (interactive) 167 (interactive)
181 (calc-radix 10) 168 (calc-radix 10))
182)
183 169
184(defun calc-binary-radix () 170(defun calc-binary-radix ()
185 (interactive) 171 (interactive)
186 (calc-radix 2) 172 (calc-radix 2))
187)
188 173
189(defun calc-octal-radix () 174(defun calc-octal-radix ()
190 (interactive) 175 (interactive)
191 (calc-radix 8) 176 (calc-radix 8))
192)
193 177
194(defun calc-hex-radix () 178(defun calc-hex-radix ()
195 (interactive) 179 (interactive)
196 (calc-radix 16) 180 (calc-radix 16))
197)
198 181
199(defun calc-leading-zeros (n) 182(defun calc-leading-zeros (n)
200 (interactive "P") 183 (interactive "P")
@@ -205,8 +188,7 @@
205 (math-compute-max-digits (math-abs calc-word-size) 188 (math-compute-max-digits (math-abs calc-word-size)
206 calc-number-radix)) 189 calc-number-radix))
207 calc-number-radix) 190 calc-number-radix)
208 (message "Omitting leading zeros on integers."))) 191 (message "Omitting leading zeros on integers."))))
209)
210 192
211 193
212(defvar math-power-of-2-cache (list 1 2 4 8 16 32 64 128 256 512 1024)) 194(defvar math-power-of-2-cache (list 1 2 4 8 16 32 64 128 256 512 1024))
@@ -228,8 +210,7 @@
228 (let ((po2 (math-ipow 2 n))) 210 (let ((po2 (math-ipow 2 n)))
229 (setq math-big-power-of-2-cache 211 (setq math-big-power-of-2-cache
230 (cons (cons n po2) math-big-power-of-2-cache)) 212 (cons (cons n po2) math-big-power-of-2-cache))
231 po2)))) 213 po2)))))
232)
233 214
234(defun math-integer-log2 (n) ; [I I] [Public] 215(defun math-integer-log2 (n) ; [I I] [Public]
235 (let ((i 0) 216 (let ((i 0)
@@ -249,8 +230,7 @@
249 n) 230 n)
250 (setq i (1+ i))) 231 (setq i (1+ i)))
251 (and (equal val n) 232 (and (equal val n)
252 i))) 233 i))))
253)
254 234
255 235
256 236
@@ -273,8 +253,7 @@
273 (t (math-clip (cons 'bigpos 253 (t (math-clip (cons 'bigpos
274 (math-and-bignum (math-binary-arg a w) 254 (math-and-bignum (math-binary-arg a w)
275 (math-binary-arg b w))) 255 (math-binary-arg b w)))
276 w))) 256 w))))
277)
278 257
279(defun math-binary-arg (a w) 258(defun math-binary-arg (a w)
280 (if (not (Math-integerp a)) 259 (if (not (Math-integerp a))
@@ -282,8 +261,7 @@
282 (if (Math-integer-negp a) 261 (if (Math-integer-negp a)
283 (math-not-bignum (cdr (math-bignum-test (math-sub -1 a))) 262 (math-not-bignum (cdr (math-bignum-test (math-sub -1 a)))
284 (math-abs (if w (math-trunc w) calc-word-size))) 263 (math-abs (if w (math-trunc w) calc-word-size)))
285 (cdr (Math-bignum-test a))) 264 (cdr (Math-bignum-test a))))
286)
287 265
288(defun math-binary-modulo-args (f a b w) 266(defun math-binary-modulo-args (f a b w)
289 (let (mod) 267 (let (mod)
@@ -312,8 +290,7 @@
312 (math-make-mod (if b 290 (math-make-mod (if b
313 (funcall f a b w) 291 (funcall f a b w)
314 (funcall f a w)) 292 (funcall f a w))
315 mod))) 293 mod))))
316)
317 294
318(defun math-and-bignum (a b) ; [l l l] 295(defun math-and-bignum (a b) ; [l l l]
319 (and a b 296 (and a b
@@ -322,8 +299,7 @@
322 (math-mul-bignum-digit (math-and-bignum (math-norm-bignum (car qa)) 299 (math-mul-bignum-digit (math-and-bignum (math-norm-bignum (car qa))
323 (math-norm-bignum (car qb))) 300 (math-norm-bignum (car qb)))
324 512 301 512
325 (logand (cdr qa) (cdr qb))))) 302 (logand (cdr qa) (cdr qb))))))
326)
327 303
328(defun calcFunc-or (a b &optional w) ; [I I I] [Public] 304(defun calcFunc-or (a b &optional w) ; [I I I] [Public]
329 (cond ((Math-messy-integerp w) 305 (cond ((Math-messy-integerp w)
@@ -341,8 +317,7 @@
341 (t (math-clip (cons 'bigpos 317 (t (math-clip (cons 'bigpos
342 (math-or-bignum (math-binary-arg a w) 318 (math-or-bignum (math-binary-arg a w)
343 (math-binary-arg b w))) 319 (math-binary-arg b w)))
344 w))) 320 w))))
345)
346 321
347(defun math-or-bignum (a b) ; [l l l] 322(defun math-or-bignum (a b) ; [l l l]
348 (and (or a b) 323 (and (or a b)
@@ -351,8 +326,7 @@
351 (math-mul-bignum-digit (math-or-bignum (math-norm-bignum (car qa)) 326 (math-mul-bignum-digit (math-or-bignum (math-norm-bignum (car qa))
352 (math-norm-bignum (car qb))) 327 (math-norm-bignum (car qb)))
353 512 328 512
354 (logior (cdr qa) (cdr qb))))) 329 (logior (cdr qa) (cdr qb))))))
355)
356 330
357(defun calcFunc-xor (a b &optional w) ; [I I I] [Public] 331(defun calcFunc-xor (a b &optional w) ; [I I I] [Public]
358 (cond ((Math-messy-integerp w) 332 (cond ((Math-messy-integerp w)
@@ -370,8 +344,7 @@
370 (t (math-clip (cons 'bigpos 344 (t (math-clip (cons 'bigpos
371 (math-xor-bignum (math-binary-arg a w) 345 (math-xor-bignum (math-binary-arg a w)
372 (math-binary-arg b w))) 346 (math-binary-arg b w)))
373 w))) 347 w))))
374)
375 348
376(defun math-xor-bignum (a b) ; [l l l] 349(defun math-xor-bignum (a b) ; [l l l]
377 (and (or a b) 350 (and (or a b)
@@ -380,8 +353,7 @@
380 (math-mul-bignum-digit (math-xor-bignum (math-norm-bignum (car qa)) 353 (math-mul-bignum-digit (math-xor-bignum (math-norm-bignum (car qa))
381 (math-norm-bignum (car qb))) 354 (math-norm-bignum (car qb)))
382 512 355 512
383 (logxor (cdr qa) (cdr qb))))) 356 (logxor (cdr qa) (cdr qb))))))
384)
385 357
386(defun calcFunc-diff (a b &optional w) ; [I I I] [Public] 358(defun calcFunc-diff (a b &optional w) ; [I I I] [Public]
387 (cond ((Math-messy-integerp w) 359 (cond ((Math-messy-integerp w)
@@ -399,8 +371,7 @@
399 (t (math-clip (cons 'bigpos 371 (t (math-clip (cons 'bigpos
400 (math-diff-bignum (math-binary-arg a w) 372 (math-diff-bignum (math-binary-arg a w)
401 (math-binary-arg b w))) 373 (math-binary-arg b w)))
402 w))) 374 w))))
403)
404 375
405(defun math-diff-bignum (a b) ; [l l l] 376(defun math-diff-bignum (a b) ; [l l l]
406 (and a 377 (and a
@@ -409,8 +380,7 @@
409 (math-mul-bignum-digit (math-diff-bignum (math-norm-bignum (car qa)) 380 (math-mul-bignum-digit (math-diff-bignum (math-norm-bignum (car qa))
410 (math-norm-bignum (car qb))) 381 (math-norm-bignum (car qb)))
411 512 382 512
412 (logand (cdr qa) (lognot (cdr qb)))))) 383 (logand (cdr qa) (lognot (cdr qb)))))))
413)
414 384
415(defun calcFunc-not (a &optional w) ; [I I] [Public] 385(defun calcFunc-not (a &optional w) ; [I I] [Public]
416 (cond ((Math-messy-integerp w) 386 (cond ((Math-messy-integerp w)
@@ -426,8 +396,7 @@
426 (t (math-normalize 396 (t (math-normalize
427 (cons 'bigpos 397 (cons 'bigpos
428 (math-not-bignum (math-binary-arg a w) 398 (math-not-bignum (math-binary-arg a w)
429 w))))) 399 w))))))
430)
431 400
432(defun math-not-bignum (a w) ; [l l] 401(defun math-not-bignum (a w) ; [l l]
433 (let ((q (math-div-bignum-digit a 512))) 402 (let ((q (math-div-bignum-digit a 512)))
@@ -437,8 +406,7 @@
437 (math-mul-bignum-digit (math-not-bignum (math-norm-bignum (car q)) 406 (math-mul-bignum-digit (math-not-bignum (math-norm-bignum (car q))
438 (- w 9)) 407 (- w 9))
439 512 408 512
440 (logxor (cdr q) 511)))) 409 (logxor (cdr q) 511)))))
441)
442 410
443(defun calcFunc-lsh (a &optional n w) ; [I I] [Public] 411(defun calcFunc-lsh (a &optional n w) ; [I I] [Public]
444 (setq a (math-trunc a) 412 (setq a (math-trunc a)
@@ -462,12 +430,10 @@
462 ((< n 0) 430 ((< n 0)
463 (math-quotient (math-clip a w) (math-power-of-2 (- n)))) 431 (math-quotient (math-clip a w) (math-power-of-2 (- n))))
464 (t 432 (t
465 (math-clip (math-mul a (math-power-of-2 n)) w))))) 433 (math-clip (math-mul a (math-power-of-2 n)) w))))))
466)
467 434
468(defun calcFunc-rsh (a &optional n w) ; [I I] [Public] 435(defun calcFunc-rsh (a &optional n w) ; [I I] [Public]
469 (calcFunc-lsh a (math-neg (or n 1)) w) 436 (calcFunc-lsh a (math-neg (or n 1)) w))
470)
471 437
472(defun calcFunc-ash (a &optional n w) ; [I I] [Public] 438(defun calcFunc-ash (a &optional n w) ; [I I] [Public]
473 (if (or (null n) 439 (if (or (null n)
@@ -497,12 +463,10 @@
497 (t (let ((two-to-n (math-power-of-2 (- n)))) 463 (t (let ((two-to-n (math-power-of-2 (- n))))
498 (math-add (calcFunc-lsh (math-add two-to-n -1) 464 (math-add (calcFunc-lsh (math-add two-to-n -1)
499 (+ w n) w) 465 (+ w n) w)
500 sh)))))))) 466 sh)))))))))
501)
502 467
503(defun calcFunc-rash (a &optional n w) ; [I I] [Public] 468(defun calcFunc-rash (a &optional n w) ; [I I] [Public]
504 (calcFunc-ash a (math-neg (or n 1)) w) 469 (calcFunc-ash a (math-neg (or n 1)) w))
505)
506 470
507(defun calcFunc-rot (a &optional n w) ; [I I] [Public] 471(defun calcFunc-rot (a &optional n w) ; [I I] [Public]
508 (setq a (math-trunc a) 472 (setq a (math-trunc a)
@@ -525,8 +489,7 @@
525 (calcFunc-rot a (math-mod n w) w)) 489 (calcFunc-rot a (math-mod n w) w))
526 (t 490 (t
527 (math-add (calcFunc-lsh a (- n w) w) 491 (math-add (calcFunc-lsh a (- n w) w)
528 (calcFunc-lsh a n w)))))) 492 (calcFunc-lsh a n w)))))))
529)
530 493
531(defun math-clip (a &optional w) ; [I I] [Public] 494(defun math-clip (a &optional w) ; [I I] [Public]
532 (cond ((Math-messy-integerp w) 495 (cond ((Math-messy-integerp w)
@@ -552,9 +515,9 @@
552 (math-normalize 515 (math-normalize
553 (cons 'bigpos 516 (cons 'bigpos
554 (math-clip-bignum (cdr (math-bignum-test (math-trunc a))) 517 (math-clip-bignum (cdr (math-bignum-test (math-trunc a)))
555 w))))) 518 w))))))
556) 519
557(fset 'calcFunc-clip (symbol-function 'math-clip)) 520(defalias 'calcFunc-clip 'math-clip)
558 521
559(defun math-clip-bignum (a w) ; [l l] 522(defun math-clip-bignum (a w) ; [l l]
560 (let ((q (math-div-bignum-digit a 512))) 523 (let ((q (math-div-bignum-digit a 512)))
@@ -564,11 +527,7 @@
564 (math-mul-bignum-digit (math-clip-bignum (math-norm-bignum (car q)) 527 (math-mul-bignum-digit (math-clip-bignum (math-norm-bignum (car q))
565 (- w 9)) 528 (- w 9))
566 512 529 512
567 (cdr q)))) 530 (cdr q)))))
568)
569
570
571
572 531
573(defvar math-max-digits-cache nil) 532(defvar math-max-digits-cache nil)
574(defun math-compute-max-digits (w r) 533(defun math-compute-max-digits (w r)
@@ -580,8 +539,7 @@
580 (digs (math-ceiling (math-div w (math-real-log2 r))))) 539 (digs (math-ceiling (math-div w (math-real-log2 r)))))
581 (setq math-max-digits-cache (cons (cons pair digs) 540 (setq math-max-digits-cache (cons (cons pair digs)
582 math-max-digits-cache)) 541 math-max-digits-cache))
583 digs))) 542 digs))))
584)
585 543
586(defvar math-log2-cache (list '(2 . 1) 544(defvar math-log2-cache (list '(2 . 1)
587 '(4 . 2) 545 '(4 . 2)
@@ -597,8 +555,7 @@
597 (calc-display-working-message nil) 555 (calc-display-working-message nil)
598 (log (calcFunc-log x 2))) 556 (log (calcFunc-log x 2)))
599 (setq math-log2-cache (cons (cons x log) math-log2-cache)) 557 (setq math-log2-cache (cons (cons x log) math-log2-cache))
600 log))) 558 log))))
601)
602 559
603(defconst math-radix-digits ["0" "1" "2" "3" "4" "5" "6" "7" "8" "9" 560(defconst math-radix-digits ["0" "1" "2" "3" "4" "5" "6" "7" "8" "9"
604 "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" 561 "A" "B" "C" "D" "E" "F" "G" "H" "I" "J"
@@ -614,8 +571,7 @@
614 (while (> a 0) 571 (while (> a 0)
615 (setq s (concat (math-format-radix-digit (% a calc-number-radix)) s) 572 (setq s (concat (math-format-radix-digit (% a calc-number-radix)) s)
616 a (/ a calc-number-radix))) 573 a (/ a calc-number-radix)))
617 s)) 574 s)))
618)
619 575
620(defconst math-binary-digits ["000" "001" "010" "011" 576(defconst math-binary-digits ["000" "001" "010" "011"
621 "100" "101" "110" "111"]) 577 "100" "101" "110" "111"])
@@ -628,8 +584,7 @@
628 (while (> a 7) 584 (while (> a 7)
629 (setq s (concat (aref math-binary-digits (% a 8)) s) 585 (setq s (concat (aref math-binary-digits (% a 8)) s)
630 a (/ a 8))) 586 a (/ a 8)))
631 (concat (math-format-radix a) s))) 587 (concat (math-format-radix a) s))))
632)
633 588
634(defun math-format-bignum-radix (a) ; [X L] 589(defun math-format-bignum-radix (a) ; [X L]
635 (cond ((null a) "0") 590 (cond ((null a) "0")
@@ -639,8 +594,7 @@
639 (t 594 (t
640 (let ((q (math-div-bignum-digit a calc-number-radix))) 595 (let ((q (math-div-bignum-digit a calc-number-radix)))
641 (concat (math-format-bignum-radix (math-norm-bignum (car q))) 596 (concat (math-format-bignum-radix (math-norm-bignum (car q)))
642 (math-format-radix-digit (cdr q)))))) 597 (math-format-radix-digit (cdr q)))))))
643)
644 598
645(defun math-format-bignum-binary (a) ; [X L] 599(defun math-format-bignum-binary (a) ; [X L]
646 (cond ((null a) "0") 600 (cond ((null a) "0")
@@ -651,8 +605,7 @@
651 (concat (math-format-bignum-binary (math-norm-bignum (car q))) 605 (concat (math-format-bignum-binary (math-norm-bignum (car q)))
652 (aref math-binary-digits (/ (cdr q) 64)) 606 (aref math-binary-digits (/ (cdr q) 64))
653 (aref math-binary-digits (% (/ (cdr q) 8) 8)) 607 (aref math-binary-digits (% (/ (cdr q) 8) 8))
654 (aref math-binary-digits (% (cdr q) 8)))))) 608 (aref math-binary-digits (% (cdr q) 8)))))))
655)
656 609
657(defun math-format-bignum-octal (a) ; [X L] 610(defun math-format-bignum-octal (a) ; [X L]
658 (cond ((null a) "0") 611 (cond ((null a) "0")
@@ -663,8 +616,7 @@
663 (concat (math-format-bignum-octal (math-norm-bignum (car q))) 616 (concat (math-format-bignum-octal (math-norm-bignum (car q)))
664 (math-format-radix-digit (/ (cdr q) 64)) 617 (math-format-radix-digit (/ (cdr q) 64))
665 (math-format-radix-digit (% (/ (cdr q) 8) 8)) 618 (math-format-radix-digit (% (/ (cdr q) 8) 8))
666 (math-format-radix-digit (% (cdr q) 8)))))) 619 (math-format-radix-digit (% (cdr q) 8)))))))
667)
668 620
669(defun math-format-bignum-hex (a) ; [X L] 621(defun math-format-bignum-hex (a) ; [X L]
670 (cond ((null a) "0") 622 (cond ((null a) "0")
@@ -674,8 +626,7 @@
674 (let ((q (math-div-bignum-digit a 256))) 626 (let ((q (math-div-bignum-digit a 256)))
675 (concat (math-format-bignum-hex (math-norm-bignum (car q))) 627 (concat (math-format-bignum-hex (math-norm-bignum (car q)))
676 (math-format-radix-digit (/ (cdr q) 16)) 628 (math-format-radix-digit (/ (cdr q) 16))
677 (math-format-radix-digit (% (cdr q) 16)))))) 629 (math-format-radix-digit (% (cdr q) 16)))))))
678)
679 630
680;;; Decompose into integer and fractional parts, without depending 631;;; Decompose into integer and fractional parts, without depending
681;;; on calc-internal-prec. 632;;; on calc-internal-prec.
@@ -690,8 +641,7 @@
690 (let ((qr (math-idivmod (nth 1 a) (math-scale-int 1 n)))) 641 (let ((qr (math-idivmod (nth 1 a) (math-scale-int 1 n))))
691 (list (car qr) (math-make-float (cdr qr) (- n)) n))) 642 (list (car qr) (math-make-float (cdr qr) (- n)) n)))
692 (list (math-scale-rounding (nth 1 a) (nth 2 a)) 643 (list (math-scale-rounding (nth 1 a) (nth 2 a))
693 '(float 0 0) 0)))) 644 '(float 0 0) 0)))))
694)
695 645
696(defun math-format-radix-float (a prec) 646(defun math-format-radix-float (a prec)
697 (let ((fmt (car calc-float-format)) 647 (let ((fmt (car calc-float-format))
@@ -798,8 +748,7 @@
798 (> calc-number-radix 14)) 748 (> calc-number-radix 14))
799 (format "%s*%d.^%s" str calc-number-radix estr) 749 (format "%s*%d.^%s" str calc-number-radix estr)
800 (format "%se%s" str estr))))))) 750 (format "%se%s" str estr)))))))
801 str) 751 str))
802)
803 752
804(defun math-convert-radix-digits (n &optional to-dec) 753(defun math-convert-radix-digits (n &optional to-dec)
805 (let ((key (cons n (cons to-dec calc-number-radix)))) 754 (let ((key (cons n (cons to-dec calc-number-radix))))
@@ -811,8 +760,8 @@
811 (cons (cons key (math-ceiling (if to-dec 760 (cons (cons key (math-ceiling (if to-dec
812 (math-mul n log) 761 (math-mul n log)
813 (math-div n log)))) 762 (math-div n log))))
814 math-radix-digits-cache))))))) 763 math-radix-digits-cache))))))))
815) 764
816(setq math-radix-digits-cache nil) 765(setq math-radix-digits-cache nil)
817 766
818(defun math-radix-float-power (n) 767(defun math-radix-float-power (n)
@@ -841,7 +790,8 @@
841 '(float 1 0) 790 '(float 1 0)
842 (math-float 791 (math-float
843 calc-number-radix)))))) 792 calc-number-radix))))))
844 math-radix-float-cache))))))) 793 math-radix-float-cache))))))))
845) 794
846(setq math-radix-float-cache-tag nil) 795(setq math-radix-float-cache-tag nil)
847 796
797;;; calc-bin.el ends here