From 88e52b073510c86b582487a65fa8ddf52a48e7dd Mon Sep 17 00:00:00 2001 From: Jelle Licht Date: Sun, 21 Mar 2021 22:39:41 +0100 Subject: [PATCH] (calc): Fix formatting of floats without decimals * lisp/calc/calc.el (math-format-number): Fix formatting for floats without decimals. --- lisp/calc/calc.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lisp/calc/calc.el b/lisp/calc/calc.el index ec09abb34c..fac9f70915 100644 --- a/lisp/calc/calc.el +++ b/lisp/calc/calc.el @@ -3193,8 +3193,9 @@ math-format-number ((= dpos 0) (setq str (concat "0" point str))) ((and (<= exp 0) (> dpos 0)) - (setq str (concat (substring str 0 dpos) point - (substring str dpos)))) + (when (> len dpos) + (setq str (concat (substring str 0 dpos) point + (substring str dpos))))) ((> exp 0) (setq str (concat str (make-string exp ?0) point))) (t ; (< dpos 0) -- 2.31.0