www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20320] New: format("%f") leeds to wrong output

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

          Issue ID: 20320
           Summary: format("%f") leeds to wrong output
           Product: D
           Version: D2
          Hardware: Other
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: bugzilla d-ecke.de

import std.stdio;
void main() {
  real a = 0.16;
  real b = 0.016;
  writefln("%.1f", a);
  writefln("%.2f", b);
}
----

Output:
---
0.2
0.01
----

I am using dmd on Windows. It doesn't happen when compiling with -m32.
----
$ dmd
DMD32 D Compiler v2.088.1-dirty

Reported by Yui Hosaka in the forum:
https://forum.dlang.org/post/pzzufbdwcgbuytxatgve forum.dlang.org

--
Oct 24 2019