"%e" floating point format and exponent digits
Andrej Mitrovic
andrej.mitrovich at gmail.com
Wed Feb 20 14:34:04 PST 2013
On 2/20/13, David Nadlinger <see at klickverbot.at> wrote:
> In Phobos, there are quite a few unit tests (std.format,
> std.json, ...) which assume that the %e floating point format
> zero-pads the exponent to (at least) two digits.
I don't know about the exponent problem, but w.r.t. floating point
there was a recent bug fixed where this source file:
auto x = 1.0;
Would be converted to this header file:
auto x = 1;
These are then different types. So I've changed how floating-point is
written in DMD to always emit "1.0" rather than "1". This also
improved diagnostics.
But I wanted to always print at most two digits in this case (e.g.
1.00, 2.00, etc) but couldn't find a good way to do it with sprintf,
so currently for floating-point e.g. "1" it prints "1.00000" in
diagnostics and header files, which is excessive.
Anyway I would definitely like to see floating-point printing
synchronized across multiple compilers and also the D library, to be
consistent everywhere.
More information about the Digitalmars-d
mailing list