Stop to! rounding?
Marco Leise
Marco.Leise at gmx.de
Wed Jul 3 10:56:28 PDT 2013
Am Tue, 2 Jul 2013 22:21:52 -0700
schrieb "H. S. Teoh" <hsteoh at quickfur.ath.cx>:
> On Tue, Jul 02, 2013 at 10:14:33PM -0700, Ali Çehreli wrote:
> [...]
> > import std.stdio;
> > import std.conv;
> >
> > void main()
> > {
> > auto a = to!double("151.42499");
> > writefln("%.60f", a);
> > }
>
> I wouldn't write it like that; IMO it's better to write:
>
> writefln("%.*f", double.dig, a);
>
> So that you don't give the wrong impression that there are more digits
> than are actually there. Using double.dig also lets you see all the
> digits that *are* there, not a rounded value, that the OP was
> complaining about.
>
>
> T
>
*f ? I didn't know that you can format the format string like
that. Thanks for the tip.
--
Marco
More information about the Digitalmars-d-learn
mailing list