D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 5602 - BigInts ignore leading spaces as in "%5d"
Summary: BigInts ignore leading spaces as in "%5d"
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: x86 Windows
: P2 enhancement
Assignee: No Owner
URL:
Keywords: patch, wrong-code
Depends on:
Blocks:
 
Reported: 2011-02-16 16:21 UTC by bearophile_hugs
Modified: 2011-09-08 13:43 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2011-02-16 16:21:58 UTC
import std.stdio, std.bigint;
void main() {
    writefln("%10d", BigInt(10));
    writefln("%10d", 10);
}


It prints:
10
        10
Comment 1 Don 2011-02-16 22:38:29 UTC
Yes, that's a limitation of std.format. It only provides the character ('x', 'd', 's', etc). The same thing applies to std.complex.
Comment 2 bearophile_hugs 2011-02-17 01:58:36 UTC
(In reply to comment #1)
> Yes, that's a limitation of std.format.

If that's a limitation meant to stay, then writef is better to give a format error (possibly at compile-time!).
Comment 3 Don 2011-02-17 04:29:48 UTC
(In reply to comment #2)
> (In reply to comment #1)
> > Yes, that's a limitation of std.format.
> 
> If that's a limitation meant to stay, then writef is better to give a format
> error (possibly at compile-time!).

Of course it's not meant to stay.
Comment 5 bearophile_hugs 2011-09-08 13:43:51 UTC
Fixed in DMD 2.055