aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorJay Belanger2007-07-07 04:15:40 +0000
committerJay Belanger2007-07-07 04:15:40 +0000
commite90988a097746c0bbef5b690d94da6541699485a (patch)
tree2fbb36ede9a7a38540880c351e86071b37d30a8e /lisp
parentdc5d263ff336489707fea113f1cf9110a281ee20 (diff)
downloademacs-e90988a097746c0bbef5b690d94da6541699485a.tar.gz
emacs-e90988a097746c0bbef5b690d94da6541699485a.zip
(math-read-number): Replace number by variable.
(math-read-number-simple): Properly parse small integers.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/calc/calc.el14
2 files changed, 16 insertions, 3 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index f362942db4c..4aedca28f86 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12007-07-07 Jay Belanger <jay.p.belanger@gmail.com>
2
3 * calc/calc.el (math-read-number): Replace number by variable.
4 (math-read-number-simple): Properly parse small integers.
5
12007-07-07 Dan Nicolaescu <dann@ics.uci.edu> 62007-07-07 Dan Nicolaescu <dann@ics.uci.edu>
2 7
3 * vc.el: Fix doc for the checkout function. 8 * vc.el: Fix doc for the checkout function.
diff --git a/lisp/calc/calc.el b/lisp/calc/calc.el
index d81c1070b9f..922a7c8d7f8 100644
--- a/lisp/calc/calc.el
+++ b/lisp/calc/calc.el
@@ -3401,6 +3401,7 @@ largest Emacs integer.")
3401 3401
3402;;; Parse a simple number in string form. [N X] [Public] 3402;;; Parse a simple number in string form. [N X] [Public]
3403(defun math-read-number (s) 3403(defun math-read-number (s)
3404 "Convert the string S into a Calc number."
3404 (math-normalize 3405 (math-normalize
3405 (cond 3406 (cond
3406 3407
@@ -3411,7 +3412,7 @@ largest Emacs integer.")
3411 (> (length digs) 1) 3412 (> (length digs) 1)
3412 (eq (aref digs 0) ?0)) 3413 (eq (aref digs 0) ?0))
3413 (math-read-number (concat "8#" digs)) 3414 (math-read-number (concat "8#" digs))
3414 (if (<= (length digs) 6) 3415 (if (<= (length digs) (* 2 math-bignum-digit-length))
3415 (string-to-number digs) 3416 (string-to-number digs)
3416 (cons 'bigpos (math-read-bignum digs)))))) 3417 (cons 'bigpos (math-read-bignum digs))))))
3417 3418
@@ -3459,13 +3460,20 @@ largest Emacs integer.")
3459 3460
3460;;; Parse a very simple number, keeping all digits. 3461;;; Parse a very simple number, keeping all digits.
3461(defun math-read-number-simple (s) 3462(defun math-read-number-simple (s)
3463 "Convert the string S into a Calc number.
3464S is assumed to be a simple number (integer or float without an exponent)
3465and all digits are kept, regardless of Calc's current precision."
3462 (cond 3466 (cond
3463 ;; Integer 3467 ;; Integer
3464 ((string-match "^[0-9]+$" s) 3468 ((string-match "^[0-9]+$" s)
3465 (cons 'bigpos (math-read-bignum s))) 3469 (if (<= (length s) (* 2 math-bignum-digit-length))
3470 (string-to-number s)
3471 (cons 'bigpos (math-read-bignum s))))
3466 ;; Minus sign 3472 ;; Minus sign
3467 ((string-match "^-[0-9]+$" s) 3473 ((string-match "^-[0-9]+$" s)
3468 (cons 'bigneg (math-read-bignum (substring s 1)))) 3474 (if (<= (length s) (1+ (* 2 math-bignum-digit-length)))
3475 (string-to-number s)
3476 (cons 'bigneg (math-read-bignum (substring s 1)))))
3469 ;; Decimal point 3477 ;; Decimal point
3470 ((string-match "^\\(-?[0-9]*\\)\\.\\([0-9]*\\)$" s) 3478 ((string-match "^\\(-?[0-9]*\\)\\.\\([0-9]*\\)$" s)
3471 (let ((int (math-match-substring s 1)) 3479 (let ((int (math-match-substring s 1))