]> git.eshelyaron.com Git - emacs.git/commitdiff
(math-read-number-simple): New function.
authorJay Belanger <jay.p.belanger@gmail.com>
Fri, 22 Jun 2007 01:05:10 +0000 (01:05 +0000)
committerJay Belanger <jay.p.belanger@gmail.com>
Fri, 22 Jun 2007 01:05:10 +0000 (01:05 +0000)
lisp/ChangeLog
lisp/calc/calc.el

index 148374e0652524646e846bfa0cac06ee0d63f0e3..0725b9d3451c49d683e33b7d22e0181e30b4fcc2 100644 (file)
@@ -1,3 +1,7 @@
+2007-06-21  Jay Belanger  <jay.p.belanger@gmail.com>
+
+       * calc/calc.el (math-read-number-simple): New function.
+
 2007-06-21  Reto Zimmermann  <reto@gnu.org>
 
        * vera-mode.el (vera-mode): Fix `commend-end-skip' setting.
index 6f37568ece4917756e5e2b9b865a6022fa0af5d2..96f93e0467b94e2f4cd12198d2df5885e9df22fc 100644 (file)
@@ -3423,6 +3423,24 @@ See calc-keypad for details."
     ;; 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))