summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2021-06-30 12:36:24 +0200
committerGitHub <noreply@github.com>2021-06-30 12:36:24 +0200
commit19263f27756e56026fe8d1ac05966b84010ae8d1 (patch)
tree8690e4f999e481d74dbf80f920f3cda322cc8c1d
parenteaa1c3a37754725f91f54f23080980b82c2f2356 (diff)
downloadNim-19263f27756e56026fe8d1ac05966b84010ae8d1.tar.gz
fixes #18400 (#18402)
-rw-r--r--lib/system/schubfach.nim2
-rw-r--r--tests/float/tfloat4.nim6
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/system/schubfach.nim b/lib/system/schubfach.nim
index d072cde99..06813f632 100644
--- a/lib/system/schubfach.nim
+++ b/lib/system/schubfach.nim
@@ -359,7 +359,7 @@ proc formatDigits(buffer: var openArray[char]; pos: int; digits: uint32; decimal
       pos = digitsEnd
     elif decimalPoint < numDigits:
       ##  dig.its
-      for i in 0..<8:
+      for i in countdown(7, 0):
         buffer[i + decimalPoint + 1] = buffer[i + decimalPoint]
       buffer[pos+decimalPoint] = '.'
       pos = digitsEnd + 1
diff --git a/tests/float/tfloat4.nim b/tests/float/tfloat4.nim
index 6a87cbe66..5bedca371 100644
--- a/tests/float/tfloat4.nim
+++ b/tests/float/tfloat4.nim
@@ -54,4 +54,10 @@ doAssert 9999999999999999.0 == "9999999999999999.0".parseFloat
 doAssert 0.999999999999999 == ".999999999999999".parseFloat
 doAssert 0.9999999999999999 == ".9999999999999999".parseFloat
 
+# bug #18400
+var s = [-13.888888'f32]
+assert $s[0] == "-13.888888"
+var x = 1.23456789012345'f32
+assert $x == "1.2345679"
+
 echo("passed all tests.")