[Bug 113] New: std.format.doFormat and small hex numbers
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Apr 21 15:07:27 PDT 2006
http://d.puremagic.com/bugzilla/show_bug.cgi?id=113
Summary: std.format.doFormat and small hex numbers
Product: D
Version: 0.154
Platform: PC
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: Phobos
AssignedTo: bugzilla at digitalmars.com
ReportedBy: fvbommel at wxs.nl
There's a bug in std.format.doFormat regarding small hexadecimals, specifically
0xA to 0xF.
This small test program demonstrates the problem:
-----
D:\Temp>cat test.d
import std.stdio;
int main()
{
for (int i = 10; i < 16; i++) writefln("%d - %x", i, i);
return 0;
}
D:\Temp>dmd -run test.d
10 - :
11 - ;
12 - <
13 - =
14 - >
15 - ?
-----
As you can see, this program doesn't produce the expected output (which would
have the lines end in a-f instead of the various punctuation marks).
Similar behavior can be observed by using std.string.format and probably
anything else that relies on std.format.doFormat to perform such formatting.
>From a quick look at the code the bug seems to originate around line 875 of
src/phobos/std/format.d where for single-character numbers (vnumber < base) the
single-character output '0'+vnumber is produced. This "optimization" seems to
result in this bug when vnumber > 9 and base > 10.
--
More information about the Digitalmars-d-bugs
mailing list