Bug 21777 – std.format: several issues when formatting integers with precision

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-03-28T09:52:03Z
Last change time
2021-04-15T07:12:15Z
Keywords
pull
Assigned to
No Owner
Creator
Berni44

Comments

Comment #0 by bugzilla — 2021-03-28T09:52:03Z
All of the following tests fail: unittest { assert(format!"%20.5,d"(cast(short) 120) == " 00,120"); // comma missing assert(format!"%20.5,o"(cast(short) 120) == " 00,170"); // comma missing assert(format!"%20.5,x"(cast(short) 120) == " 00,078"); // one space too much assert(format!"%20.5,2d"(cast(short) 120) == " 0,01,20"); // one space too much assert(format!"%20.5,2o"(cast(short) 120) == " 0,01,70"); // one space too much assert(format!"%20.5,4d"(cast(short) 120) == " 0,0120"); // comma missing assert(format!"%20.5,4o"(cast(short) 120) == " 0,0170"); // comma missing assert(format!"%20.5,4x"(cast(short) 120) == " 0,0170"); // comma missing assert(format!"%20.5,2x"(3000) == " 0,0b,b8"); // one space too much assert(format!"%20.5,4d"(3000) == " 0,3000"); // comma missing assert(format!"%20.5,4o"(3000) == " 0,5670"); // comma missing assert(format!"%20.5,4x"(3000) == " 0,0bb8"); // comma missing assert(format!"%20.5,d"(-400) == " -0,0400"); // one space too much assert(format!"%20.30d"(-400) == "-00000000000000000000000000400"); // one zero too much }
Comment #1 by bugzilla — 2021-03-28T13:42:34Z
One more: assert(format!"%20.5,4d"(0) == " 0,0000"); // comma is in the wrong place
Comment #2 by bugzilla — 2021-04-11T15:27:16Z
Two more: assert(format!"%0#.8,2s"(12345) == "00,01,23,45"); assert(format!"%0#.9,3x"(55) == "0x000,000,037");
Comment #3 by dlang-bot — 2021-04-13T20:05:01Z
@berni44 created dlang/phobos pull request #7965 "std.format: New version for formatting integral values using writeAligned" fixing this issue: - Fix Issue 21777 - std.format: several issues when formatting integers with precision https://github.com/dlang/phobos/pull/7965
Comment #4 by dlang-bot — 2021-04-15T07:12:15Z
dlang/phobos pull request #7965 "std.format: New version for formatting integral values using writeAligned" was merged into master: - 5e180880cb04994b8dc9d88e38e9046f43c5b1d5 by berni44: Fix Issue 21777 - std.format: several issues when formatting integers with precision https://github.com/dlang/phobos/pull/7965