[Issue 20536] New: std.format: %a on real gives wrong result

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jan 26 17:06:00 UTC 2020


https://issues.dlang.org/show_bug.cgi?id=20536

          Issue ID: 20536
           Summary: std.format: %a on real gives wrong result
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: bugzilla at d-ecke.de

On my computer the format command below produces "0x8p-23" which is inconsitent
with the results from float/double, where the first digit after "0x" is always
a 1 (leaving aside corner cases). The test below should work independent of the
type of real used.

void main()
{
    import std.format : format;

    real r = .00000095367431640625L;

    assert(format("%a", r) == "0x1p-20"); // fails
}

--


More information about the Digitalmars-d-bugs mailing list