fix strformat zeropadding for floats (#7934)
This commit is contained in:
parent
b4626a220b
commit
07ff9940f4
2 changed files with 30 additions and 3 deletions
|
|
@ -10,4 +10,13 @@ proc `$`(o: Obj): string = "foobar"
|
|||
|
||||
var o: Obj
|
||||
doAssert fmt"{o}" == "foobar"
|
||||
doAssert fmt"{o:10}" == "foobar "
|
||||
doAssert fmt"{o:10}" == "foobar "
|
||||
|
||||
# see issue #7932
|
||||
doAssert fmt"{15:08}" == "00000015" # int, works
|
||||
doAssert fmt"{1.5:08}" == "000001.5" # float, works
|
||||
doAssert fmt"{1.5:0>8}" == "000001.5" # workaround using fill char works for positive floats
|
||||
doAssert fmt"{-1.5:0>8}" == "0000-1.5" # even that does not work for negative floats
|
||||
doAssert fmt"{-1.5:08}" == "-00001.5" # works
|
||||
doAssert fmt"{1.5:+08}" == "+00001.5" # works
|
||||
doAssert fmt"{1.5: 08}" == " 00001.5" # works
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue