[Issue 19939] New: std.format %13,3.2f does not count width correctly
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Jun 5 00:16:07 UTC 2019
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 at puremagic.com
Reporter: hsteoh at 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.
--
More information about the Digitalmars-d-bugs
mailing list