# HG changeset patch # User Jay Belanger # Date 1258329717 0 # Node ID f0c7d6481a537d160dc380d16ffb2e9a22ea6bed # Parent 84036421a1d0736883aa0232f3da4e28ca791644 (math-read-number-fancy): Read complement signed numbers. (calc-init-extensions): Add binding for `calc-symclip'. Add autoloads for `calcFunc-symclip' and `calc-symclip'. diff -r 84036421a1d0 -r f0c7d6481a53 lisp/calc/calc-ext.el --- 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))