Re: Printing floating point numbers

2019-10-25 Thread berni44 via Digitalmars-d-learn
On Friday, 25 October 2019 at 14:51:33 UTC, Yui Hosaka wrote: The outputs for your program are as follows: [...] Thanks for the output. I added it to the bug report. The internal representation of the value is correct in all versions. While the result of the direct call of snprintf always gi

Re: Printing floating point numbers

2019-10-25 Thread Yui Hosaka via Digitalmars-d-learn
On Friday, 25 October 2019 at 06:53:38 UTC, berni44 wrote: On Thursday, 24 October 2019 at 20:48:02 UTC, Yui Hosaka wrote: Do you have any idea for this issue? I added a bug report: https://issues.dlang.org/show_bug.cgi?id=20320 Internally the conversation from the binary representation of

Re: Printing floating point numbers

2019-10-24 Thread berni44 via Digitalmars-d-learn
On Thursday, 24 October 2019 at 20:48:02 UTC, Yui Hosaka wrote: Do you have any idea for this issue? I added a bug report: https://issues.dlang.org/show_bug.cgi?id=20320 Internally the conversation from the binary representation of the value to the printed one is done by a call to a C funct

Re: Printing floating point numbers

2019-10-24 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 24 October 2019 at 20:48:02 UTC, Yui Hosaka wrote: Do you have any idea for this issue? my suspicion would be that .016 is actually represented as .015 and the .2 round ignores all those 9's...

Printing floating point numbers

2019-10-24 Thread Yui Hosaka via Digitalmars-d-learn
The following code prints weird results on my machine. 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