bug? floating point precision with std.format

2017-06-05 Thread Steven Schveighoffer via Digitalmars-d
It appears that the precision parameter in std.format differs from its meaning in printf. Is that expected behavior? Example: import std.stdio; import core.stdc.stdio; void main() { auto f = 20.6; writeln(f); writefln("%0.3s", f); printf("%0.3f\n", f); } prints: 20.6667 20

Re: bug? floating point precision with std.format

2017-06-05 Thread Seb via Digitalmars-d
On Monday, 5 June 2017 at 15:37:42 UTC, Steven Schveighoffer wrote: It appears that the precision parameter in std.format differs from its meaning in printf. Is that expected behavior? Example: import std.stdio; import core.stdc.stdio; void main() { auto f = 20.6; writeln(f);

Re: bug? floating point precision with std.format

2017-06-05 Thread H. S. Teoh via Digitalmars-d
On Mon, Jun 05, 2017 at 04:29:06PM +, Seb via Digitalmars-d wrote: > On Monday, 5 June 2017 at 15:37:42 UTC, Steven Schveighoffer wrote: > > It appears that the precision parameter in std.format differs from its > > meaning in printf. Is that expected behavior? > > > > Example: > > > > import

Re: bug? floating point precision with std.format

2017-06-05 Thread Steven Schveighoffer via Digitalmars-d
On 6/5/17 12:53 PM, H. S. Teoh via Digitalmars-d wrote: On Mon, Jun 05, 2017 at 04:29:06PM +, Seb via Digitalmars-d wrote: On Monday, 5 June 2017 at 15:37:42 UTC, Steven Schveighoffer wrote: It appears that the precision parameter in std.format differs from its meaning in printf. Is that ex

Re: bug? floating point precision with std.format

2017-06-05 Thread Steven Schveighoffer via Digitalmars-d
On 6/5/17 12:29 PM, Seb wrote: You do realize that you have used "s" in the D version? Yes, I thought it was a stand in for "use the type to determine the specifier", and I mistakenly assumed that would be 'f', since that's what I've always used for floating point. Apparently it is 'g', which

Re: bug? floating point precision with std.format

2017-06-05 Thread Jonathan M Davis via Digitalmars-d
On Monday, June 05, 2017 13:23:38 Steven Schveighoffer via Digitalmars-d wrote: > On 6/5/17 12:29 PM, Seb wrote: > > You do realize that you have used "s" in the D version? > > Yes, I thought it was a stand in for "use the type to determine the > specifier", and I mistakenly assumed that would be