# HG changeset patch # User Jay Belanger # Date 1182474204 0 # Node ID 041563cafc0462ad7cc2a81760f2e4ce452a6377 # Parent b895cdfeedc57616749921653b516b4f4a33d701 (math-read-number-simple): New function. diff -r b895cdfeedc5 -r 041563cafc04 lisp/calc/calc.el --- a/lisp/calc/calc.el Thu Jun 21 23:02:14 2007 +0000 +++ b/lisp/calc/calc.el Fri Jun 22 01:03:24 2007 +0000 @@ -3423,6 +3423,24 @@ ;; Syntax error! (t nil)))) +;;; Parse a very simple number, keeping all digits. +(defun math-read-number-simple (s) + (cond + ;; Integer + ((string-match "^[0-9]+$" s) + (cons 'bigpos (math-read-bignum s))) + ;; Minus sign + ((string-match "^-[0-9]+$" s) + (cons 'bigneg (math-read-bignum (substring s 1)))) + ;; Decimal point + ((string-match "^\\(-?[0-9]*\\)\\.\\([0-9]*\\)$" s) + (let ((int (math-match-substring s 1)) + (frac (math-match-substring s 2))) + (list 'float (math-read-number-simple (concat int frac)) + (- (length frac))))) + ;; Syntax error! + (t nil))) + (defun math-match-substring (s n) (if (match-beginning n) (substring s (match-beginning n) (match-end n))