emacs-diffs
[Top][All Lists]
Advanced

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

master b1fe27d: Fix calculator entry of numbers with negative exponents


From: Mattias Engdegård
Subject: master b1fe27d: Fix calculator entry of numbers with negative exponents (bug#41347)
Date: Mon, 18 May 2020 05:28:06 -0400 (EDT)

branch: master
commit b1fe27d77db8f819641231ca46725f3eed0b4d9b
Author: Mattias Engdegård <address@hidden>
Commit: Mattias Engdegård <address@hidden>

    Fix calculator entry of numbers with negative exponents (bug#41347)
    
    * lisp/calculator.el (calculator-string-to-number):
    Remove obsolete string transformations preventing entry of 1e-3 etc.
    Keep one transformation to allow entry of "1.e3".
    Reported by Chris Zheng.
---
 lisp/calculator.el | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/lisp/calculator.el b/lisp/calculator.el
index 7e0b2fc..cd92f99 100644
--- a/lisp/calculator.el
+++ b/lisp/calculator.el
@@ -858,12 +858,10 @@ The result should not exceed the screen width."
   "Convert the given STR to a number, according to the value of
 `calculator-input-radix'."
   (if calculator-input-radix
-    (string-to-number str (cadr (assq calculator-input-radix
-                                      '((bin 2) (oct 8) (hex 16)))))
-    (let* ((str (replace-regexp-in-string
-                 "\\.\\([^0-9].*\\)?$" ".0\\1" str))
-           (str (replace-regexp-in-string
-                 "[eE][+-]?\\([^0-9].*\\)?$" "e0\\1" str)))
+      (string-to-number str (cadr (assq calculator-input-radix
+                                        '((bin 2) (oct 8) (hex 16)))))
+    ;; Allow entry of "1.e3".
+    (let ((str (replace-regexp-in-string (rx "." (any "eE")) "e" str)))
       (float (string-to-number str)))))
 
 (defun calculator-push-curnum ()



reply via email to

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