diff options
| author | Mattias EngdegÄrd | 2020-05-17 18:11:27 +0200 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2020-05-18 11:27:40 +0200 |
| commit | b1fe27d77db8f819641231ca46725f3eed0b4d9b (patch) | |
| tree | 6f21824ca4c36f3fcd7968bc40c7d853c7dea1f9 | |
| parent | 2216468786f64cfa403dface1dab1cd20b84d5aa (diff) | |
| download | emacs-b1fe27d77db8f819641231ca46725f3eed0b4d9b.tar.gz emacs-b1fe27d77db8f819641231ca46725f3eed0b4d9b.zip | |
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.
| -rw-r--r-- | lisp/calculator.el | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/lisp/calculator.el b/lisp/calculator.el index 7e0b2fcc6a3..cd92f992689 100644 --- a/lisp/calculator.el +++ b/lisp/calculator.el | |||
| @@ -858,12 +858,10 @@ The result should not exceed the screen width." | |||
| 858 | "Convert the given STR to a number, according to the value of | 858 | "Convert the given STR to a number, according to the value of |
| 859 | `calculator-input-radix'." | 859 | `calculator-input-radix'." |
| 860 | (if calculator-input-radix | 860 | (if calculator-input-radix |
| 861 | (string-to-number str (cadr (assq calculator-input-radix | 861 | (string-to-number str (cadr (assq calculator-input-radix |
| 862 | '((bin 2) (oct 8) (hex 16))))) | 862 | '((bin 2) (oct 8) (hex 16))))) |
| 863 | (let* ((str (replace-regexp-in-string | 863 | ;; Allow entry of "1.e3". |
| 864 | "\\.\\([^0-9].*\\)?$" ".0\\1" str)) | 864 | (let ((str (replace-regexp-in-string (rx "." (any "eE")) "e" str))) |
| 865 | (str (replace-regexp-in-string | ||
| 866 | "[eE][+-]?\\([^0-9].*\\)?$" "e0\\1" str))) | ||
| 867 | (float (string-to-number str))))) | 865 | (float (string-to-number str))))) |
| 868 | 866 | ||
| 869 | (defun calculator-push-curnum () | 867 | (defun calculator-push-curnum () |