D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 21776 - %b, %o, %x and %X on integers does not obey plus and space flag
Summary: %b, %o, %x and %X on integers does not obey plus and space flag
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-03-28 08:45 UTC by Berni44
Modified: 2021-04-10 06:12 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Berni44 2021-03-28 08:45:23 UTC
All asserts fail, while with %d they work.

unittest
{
    assert(format!"%+b"(15) == "+1111");
    assert(format!"%+o"(15) == "+17");
    assert(format!"%+x"(15) == "+f");
    assert(format!"%+X"(15) == "+F");

    assert(format!"% b"(15) == " 1111");
    assert(format!"% o"(15) == " 17");
    assert(format!"% x"(15) == " f");
    assert(format!"% X"(15) == " F");
}
Comment 1 Berni44 2021-04-10 06:12:37 UTC
Meanwhile I think, this is intentional: These format characters give the image of the bit pattern, which means, there is no sign. So closing this as invalid.