www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [patch] the age-old std.format bug

So, std.format has problems on Linux since
printf in glibc doesn't like long doubles...
This has broken the Phobos unittest for a
few months now, which isn't all that good ?
(sorta bad advertising for having unittests)

In the spirit of "Dr, it hurts when I do this"
I just removed the upsampling of floats and
doubles to the trouble-some real format, and
instead made a separate double function using
the infamous code-reuse technique copy'n'paste.
(where floats also use this new double function)


TEST:
std.string.format(1.67, " %A ", -1.28, float.nan);

BEFORE:
 1.67 -0XA.3D70A3D70A3D8P-3 nan
AFTER:
 1.67 -0X1.47AE147AE147BP+0 nan
(the patch makes snprintf use "%A" instead of "%LA") Besides, platforms such as Mac OS X and other PPC does not have a "real" type yet anyway, which makes it even less use to have that default on that CPU... Eventually, "real" can be simulated on PPC using two doubles just as "long" could be now - using two ints. But, long before that, format's unittest should pass! This closes bugs: (in the imaginary Bugzilla for D) http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D.bugs/2500 http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D.bugs/2022 --anders
Feb 06 2005