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 }
One more: assert(format!"%20.5,4d"(0) == " 0,0000"); // comma is in the wrong place
Two more: assert(format!"%0#.8,2s"(12345) == "00,01,23,45"); assert(format!"%0#.9,3x"(55) == "0x000,000,037");
@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
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