import std.stdio; void main() { float a = -999999.8125; writefln!"%#.1g"(a); writefln!"%#.2g"(a); writefln!"%#.3g"(a); writefln!"%#.4g"(a); writefln!"%#.5g"(a); writefln!"%#.6g"(a); writefln!"%#.7g"(a); writefln!"%#.8g"(a); writefln!"%#.9g"(a); } produces: -1.e+06 -1.0e+06 -1.00e+06 -1.000e+06 -1.0000e+06 -1.e+06 -999999.8 -999999.81 -999999.812 The sixth line is inconsistent, should be -1.00000e+06.
@berni44 created dlang/phobos pull request #7804 "std.format: format floats and doubles with %g / %G / %s" fixing this issue: - Fix 21641 - std.format: %g produces in rare circumstances inconsistent result https://github.com/dlang/phobos/pull/7804
@berni44 created dlang/phobos pull request #7853 "Format add g final step" fixing this issue: - Fix 21641 - std.format: %g produces in rare circumstances inconsistent result https://github.com/dlang/phobos/pull/7853
dlang/phobos pull request #7853 "Format add g final step" was merged into master: - bfcd65e71efd3737d2383266d719083685ef2939 by berni44: Fix 21641 - std.format: %g produces in rare circumstances inconsistent result https://github.com/dlang/phobos/pull/7853