digitalmars.D.bugs - [Issue 19939] New: std.format %13,3.2f does not count width correctly
- d-bugmail puremagic.com (52/52) Jun 04 2019 https://issues.dlang.org/show_bug.cgi?id=19939
https://issues.dlang.org/show_bug.cgi?id=19939 Issue ID: 19939 Summary: std.format %13,3.2f does not count width correctly Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: phobos Assignee: nobody puremagic.com Reporter: hsteoh quickfur.ath.cx Example code: ------- import std.stdio; void main() { writefln("^%13,3.2f$", 1.00); writefln("^%13,3.2f$", 10.00); writefln("^%13,3.2f$", 100.00); writefln("^%13,3.2f$", 1_000.00); writefln("^%13,3.2f$", 10_000.00); writefln("^%13,3.2f$", 100_000.00); writefln("^%13,3.2f$", 1_000_000.00); writefln("^%13,3.2f$", 10_000_000.00); } ------- Expected output: ------- ^ 1.00$ ^ 10.00$ ^ 100.00$ ^ 1,000.00$ ^ 10,000.00$ ^ 100,000.00$ ^ 1,000,000.00$ ^10,000,000.00$ ------- Actual output: ------- ^ 1.00$ ^ 10.00$ ^ 100.00$ ^ 1,000.00$ ^ 10,000.00$ ^ 100,000.00$ ^ 1,000,000.00$ ^10,000,000.00$ ------- It seems that there is an off-by-1 error in the reckoning for width when formatting floating-point values with a format that contains a `,n` flag. --
Jun 04 2019