branch: externals/shift-number
commit cfe8e90591ec3271cb901cc34b68f2ca3d858c1f
Author: Campbell Barton <[email protected]>
Commit: Campbell Barton <[email protected]>

    Fix incrementing a negative number resulting in -0
---
 shift-number.el | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/shift-number.el b/shift-number.el
index b6723f8ad9..39fcbe7594 100644
--- a/shift-number.el
+++ b/shift-number.el
@@ -213,8 +213,14 @@ Otherwise search forward limited by LIMIT-END."
 
         ;; Handle sign flipping & negative numbers.
         (when use-sign
-          (when (< new-num 0)
+          (cond
+           ((< new-num 0)
             (setq new-sign (- old-sign)))
+           ;; Without this check -1 would increase to -0.
+           ;; While technically correct, it's not desirable.
+           ((zerop new-num)
+            (when (eq old-sign -1)
+              (setq new-sign 1))))
 
           (cond
            ((eq new-sign -1)

Reply via email to