Bug 19939 – std.format %13,3.2f does not count width correctly

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2019-06-05T00:16:07Z
Last change time
2019-06-17T05:46:05Z
Keywords
pull
Assigned to
No Owner
Creator
hsteoh

Comments

Comment #0 by hsteoh — 2019-06-05T00:16:07Z
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.
Comment #1 by dlang-bot — 2019-06-12T12:14:41Z
@shove70 created dlang/phobos pull request #7067 "Fix issue 19939 - std.format count width error" fixing this issue: - Fix issue 19939 - std.format count width error https://github.com/dlang/phobos/pull/7067
Comment #2 by dlang-bot — 2019-06-12T12:59:29Z
@shove70 created dlang/phobos pull request #7068 "Fix issue 19939 - std.format count width error" fixing this issue: - Fix issue 19939 - std.format count width error https://github.com/dlang/phobos/pull/7068
Comment #3 by dlang-bot — 2019-06-17T05:46:05Z
dlang/phobos pull request #7068 "Fix issue 19939 - std.format count width error" was merged into stable: - db35ee5eb1c3ab90c1d352f4b1c62590cb44552b by shove: Fix issue 19939 - std.format count width error https://github.com/dlang/phobos/pull/7068