Float to string with more digits?

Justin Whear via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Feb 24 12:08:55 PST 2015


On Tue, 24 Feb 2015 20:04:04 +0000, Almighty Bob wrote:

> Is there a more accurate way to do a float and or double to string
> than...
> 
> to!string(float);
> 
> As that seems to limit itself to 6 digits.

Use std.string.format or std.format.formattedWrite.  std.format contains 
a description of the various format specifiers.  You'll probably want 
something like "%.12f", which formats a floating point number with 12 
digits of precision.


More information about the Digitalmars-d-learn mailing list