Bug 21641 – std.format: %g produces in rare circumstances inconsistent result

Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2021-02-16T18:01:04Z
Last change time
2021-03-13T15:36:28Z
Keywords
pull
Assigned to
No Owner
Creator
Berni44

Comments

Comment #0 by bugzilla — 2021-02-16T18:01:04Z
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.
Comment #1 by dlang-bot — 2021-02-18T17:06:52Z
@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
Comment #2 by dlang-bot — 2021-03-13T07:52:58Z
@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
Comment #3 by dlang-bot — 2021-03-13T15:36:28Z
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