summaryrefslogtreecommitdiff
path: root/lisp/calc/calc-ext.el
diff options
context:
space:
mode:
authorJay Belanger <jay.p.belanger@gmail.com>2009-11-16 00:01:57 +0000
committerJay Belanger <jay.p.belanger@gmail.com>2009-11-16 00:01:57 +0000
commit6f1b89435a2f9018b91e8b5d23d85e37f799b533 (patch)
treecdbfdb6bc3e7efcef3d4db09ef62b226efabd5ec /lisp/calc/calc-ext.el
parent802732d0336e1c87ffb6998815b7287972d390dd (diff)
(math-read-number-fancy): Read complement signed numbers.
(calc-init-extensions): Add binding for `calc-symclip'. Add autoloads for `calcFunc-symclip' and `calc-symclip'.
Diffstat (limited to 'lisp/calc/calc-ext.el')
-rw-r--r--lisp/calc/calc-ext.el21
1 files changed, 16 insertions, 5 deletions
diff --git a/lisp/calc/calc-ext.el b/lisp/calc/calc-ext.el
index 80899e78ca..f1bbdfab37 100644
--- a/lisp/calc/calc-ext.el
+++ b/lisp/calc/calc-ext.el
@@ -198,6 +198,7 @@
(define-key calc-mode-map "bo" 'calc-or)
(define-key calc-mode-map "bp" 'calc-pack-bits)
(define-key calc-mode-map "br" 'calc-rshift-binary)
+ (define-key calc-mode-map "bs" 'calc-symclip)
(define-key calc-mode-map "bt" 'calc-rotate-binary)
(define-key calc-mode-map "bu" 'calc-unpack-bits)
(define-key calc-mode-map "bw" 'calc-word-size)
@@ -762,7 +763,7 @@ math-quarter-integer math-round math-setup-declarations math-sqr
math-sqr-float math-trunc-fancy math-trunc-special)
("calc-bin" calcFunc-and calcFunc-ash
-calcFunc-clip calcFunc-diff calcFunc-lsh calcFunc-not calcFunc-or
+calcFunc-clip calcFunc-diff calcFunc-symclip calcFunc-lsh calcFunc-not calcFunc-or
calcFunc-rash calcFunc-rot calcFunc-rsh calcFunc-xor math-clip
math-compute-max-digits math-convert-radix-digits math-float-parts
math-format-bignum-binary math-format-bignum-hex
@@ -987,9 +988,9 @@ calc-find-root calc-poly-interp)
calc-floor calc-idiv calc-increment calc-mant-part calc-max calc-min
calc-round calc-scale-float calc-sign calc-trunc calc-xpon-part)
- ("calc-bin" calc-and calc-binary-radix calc-clip calc-decimal-radix
-calc-diff calc-hex-radix calc-leading-zeros calc-lshift-arith
-calc-lshift-binary calc-not calc-octal-radix calc-or calc-radix
+ ("calc-bin" calc-and calc-binary-radix calc-clip calc-complement-signed-mode
+calc-decimal-radix calc-diff calc-hex-radix calc-symclip calc-leading-zeros
+calc-lshift-arith calc-lshift-binary calc-not calc-octal-radix calc-or calc-radix
calc-rotate-binary calc-rshift-arith calc-rshift-binary calc-word-size
calc-xor)
@@ -2994,10 +2995,20 @@ If X is not an error form, return 1."
(math-add int (math-div frac (math-pow radix (length fracs))))))))
;; Integer with explicit radix
- ((string-match "^\\([0-9]+\\)\\(#\\|\\^\\^\\)\\([0-9a-zA-Z]+\\)$" s)
+ ((string-match "^\\([0-9]+\\)\\(#&?\\|\\^\\^\\)\\([0-9a-zA-Z]+\\)$" s)
(math-read-radix (math-match-substring s 3)
(string-to-number (math-match-substring s 1))))
+ ;; Complement signed with explicit radix
+ ((string-match "^\\([0-9]+\\)\\(##\\)\\([0-9a-zA-Z]+\\)$" s)
+ (let ((num (math-read-radix (math-match-substring s 3)
+ (string-to-number (math-match-substring s 1)))))
+ (if (and
+ (Math-lessp num math-2-word-size)
+ (<= (math-compare math-half-2-word-size num) 0))
+ (math-sub num math-2-word-size)
+ num)))
+
;; C language hexadecimal notation
((and (eq calc-language 'c)
(string-match "^0[xX]\\([0-9a-fA-F]+\\)$" s))