diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pure/strformat.nim | 4 | ||||
-rw-r--r-- | lib/pure/strutils.nim | 7 |
2 files changed, 4 insertions, 7 deletions
diff --git a/lib/pure/strformat.nim b/lib/pure/strformat.nim index 838baaf02..5f7ef380d 100644 --- a/lib/pure/strformat.nim +++ b/lib/pure/strformat.nim @@ -692,11 +692,11 @@ when isMainModule: check &"{-123.456:.3f}", "-123.456" check &"{123.456:1g}", "123.456" check &"{123.456:.1f}", "123.5" - check &"{123.456:.0f}", "123" + check &"{123.456:.0f}", "123." check &"{123.456:>9.3f}", " 123.456" check &"{123.456:9.3f}", " 123.456" check &"{123.456:>9.4f}", " 123.4560" - check &"{123.456:>9.0f}", " 123" + check &"{123.456:>9.0f}", " 123." check &"{123.456:<9.4f}", "123.4560 " # Float (scientific) tests diff --git a/lib/pure/strutils.nim b/lib/pure/strutils.nim index ff76fa94f..a1f80ad76 100644 --- a/lib/pure/strutils.nim +++ b/lib/pure/strutils.nim @@ -2430,10 +2430,6 @@ proc formatBiggestFloat*(f: BiggestFloat, format: FloatFormatMode = ffDefault, # but nothing else is possible: if buf[i] in {'.', ','}: result[i] = decimalSep else: result[i] = buf[i] - since (1, 1): - # remove trailing dot, compatible with Python's formatter and JS backend - if result[^1] == decimalSep: - result.setLen(len(result)-1) when defined(windows): # VS pre 2015 violates the C standard: "The exponent always contains at # least two digits, and only as many more digits as necessary to @@ -2936,7 +2932,8 @@ proc isNilOrWhitespace*(s: string): bool {.noSideEffect, procvar, rtl, when isMainModule: proc nonStaticTests = doAssert formatBiggestFloat(1234.567, ffDecimal, -1) == "1234.567000" - doAssert formatBiggestFloat(1234.567, ffDecimal, 0) == "1235" # bugs 8242, 12586 + when not defined(js): + doAssert formatBiggestFloat(1234.567, ffDecimal, 0) == "1235." # bugs 8242, 12586 doAssert formatBiggestFloat(1234.567, ffDecimal, 1) == "1234.6" doAssert formatBiggestFloat(0.00000000001, ffDecimal, 11) == "0.00000000001" doAssert formatBiggestFloat(0.00000000001, ffScientific, 1, ',') in |