[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] branch main updated: (ice-9 format): Fix scaling floats
From: |
Daniel Llorens |
Subject: |
[Guile-commits] branch main updated: (ice-9 format): Fix scaling floats with leading zeros |
Date: |
Mon, 18 Oct 2021 21:01:51 -0400 |
This is an automated email from the git hooks/post-receive script.
lloda pushed a commit to branch main
in repository guile.
The following commit(s) were added to refs/heads/main by this push:
new c85724b (ice-9 format): Fix scaling floats with leading zeros
c85724b is described below
commit c85724bd0a72a11f8c28c844a200d624ce32958a
Author: Timothy Sample <samplet@ngyro.com>
AuthorDate: Tue Oct 19 02:50:51 2021 +0200
(ice-9 format): Fix scaling floats with leading zeros
---
module/ice-9/format.scm | 4 ++--
test-suite/tests/format.test | 8 +++++++-
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/module/ice-9/format.scm b/module/ice-9/format.scm
index 48d9c0c..ee7cba9 100644
--- a/module/ice-9/format.scm
+++ b/module/ice-9/format.scm
@@ -1359,10 +1359,10 @@
(else
(if (> left-zeros 0)
(if (<= left-zeros shift) ; shift always > 0 here
- (format:fn-shiftleft shift) ; shift out 0s
(begin
(format:fn-shiftleft left-zeros)
- (set! format:fn-dot (- shift left-zeros))))
+ (set! format:fn-dot (- shift left-zeros)))
+ (format:fn-shiftleft shift)) ; shift out 0s
(set! format:fn-dot (+ format:fn-dot shift))))))))
(let ((negexp ; expon format m.nnnEee
diff --git a/test-suite/tests/format.test b/test-suite/tests/format.test
index b9aa7a8..f32d995 100644
--- a/test-suite/tests/format.test
+++ b/test-suite/tests/format.test
@@ -121,7 +121,13 @@
;; in guile prior to 1.6.9 and 1.8.1, leading zeros were incorrectly
;; stripped, moving the decimal point and giving "25.0" here
(pass-if "string 02.5"
- (string=? "2.5" (format #f "~f" "02.5"))))
+ (string=? "2.5" (format #f "~f" "02.5")))
+
+ (pass-if "scale with few leading zeros"
+ (string=? "1.23" (format #f "~,,3f" "0.00123")))
+
+ (pass-if "scale with many leading zeros"
+ (string=? "0.0123" (format #f "~,,1f" "0.00123"))))
;;;
;;; ~h
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Guile-commits] branch main updated: (ice-9 format): Fix scaling floats with leading zeros,
Daniel Llorens <=