emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/calc/calc.el,v


From: Jay Belanger
Subject: [Emacs-diffs] Changes to emacs/lisp/calc/calc.el,v
Date: Fri, 22 Jun 2007 01:03:27 +0000

CVSROOT:        /cvsroot/emacs
Module name:    emacs
Changes by:     Jay Belanger <jpb>      07/06/22 01:03:25

Index: calc.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/calc/calc.el,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -b -r1.79 -r1.80
--- calc.el     20 Jun 2007 19:32:49 -0000      1.79
+++ calc.el     22 Jun 2007 01:03:24 -0000      1.80
@@ -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))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]