changeset 106040:f0c7d6481a53

(math-read-number-fancy): Read complement signed numbers. (calc-init-extensions): Add binding for `calc-symclip'. Add autoloads for `calcFunc-symclip' and `calc-symclip'.
author Jay Belanger <jay.p.belanger@gmail.com>
date Mon, 16 Nov 2009 00:01:57 +0000
parents 84036421a1d0
children 05e547365764
files lisp/calc/calc-ext.el
diffstat 1 files changed, 16 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/calc/calc-ext.el	Mon Nov 16 00:01:17 2009 +0000
+++ b/lisp/calc/calc-ext.el	Mon Nov 16 00:01:57 2009 +0000
@@ -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-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-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 @@
 	     (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))