Re: Full precision double to string conversion

2018-11-03 Thread Ecstatic Coder via Digitalmars-d-learn
On Saturday, 3 November 2018 at 18:04:07 UTC, Stanislav Blinov wrote: On Saturday, 3 November 2018 at 17:26:19 UTC, Ecstatic Coder wrote: void main() { double value = -12.000123456; int precision = 50; import std.stdio; writefln("%.*g", precision, value); import

Re: Full precision double to string conversion

2018-11-03 Thread Stanislav Blinov via Digitalmars-d-learn
On Saturday, 3 November 2018 at 17:26:19 UTC, Ecstatic Coder wrote: void main() { double value = -12.000123456; int precision = 50; import std.stdio; writefln("%.*g", precision, value); import std.format; string str = format("%.*g", precision, value);

Re: Full precision double to string conversion

2018-11-03 Thread Ecstatic Coder via Digitalmars-d-learn
Actually, what I need is the D equivalent of the default ToString() function we have in Dart and C#. I don't think it means what you think it means: void main() { double value = -12.000123456; int precision = 50; import std.stdio; writefln("%.*g", precision, value);

Re: Full precision double to string conversion

2018-11-03 Thread Stanislav Blinov via Digitalmars-d-learn
On Saturday, 3 November 2018 at 13:20:22 UTC, Ecstatic Coder wrote: On Saturday, 3 November 2018 at 12:45:03 UTC, Danny Arends wrote: How can I convert a double value -12.000123456 to its string value "-12.000123456", i.e. without loosing double-precision digits ? Specify how many digits

Re: Full precision double to string conversion

2018-11-03 Thread Ecstatic Coder via Digitalmars-d-learn
On Saturday, 3 November 2018 at 12:45:03 UTC, Danny Arends wrote: On Saturday, 3 November 2018 at 12:27:19 UTC, Ecstatic Coder wrote: import std.conv; import std.stdio; void main() { double value = -12.000123456; writeln( value.sizeof ); writeln( value ); writeln(

Re: Full precision double to string conversion

2018-11-03 Thread Danny Arends via Digitalmars-d-learn
On Saturday, 3 November 2018 at 12:27:19 UTC, Ecstatic Coder wrote: import std.conv; import std.stdio; void main() { double value = -12.000123456; writeln( value.sizeof ); writeln( value ); writeln( value.to!string() ); writeln( value.to!dstring() ); } /* 8 -12.0001 -12.0001

Full precision double to string conversion

2018-11-03 Thread Ecstatic Coder via Digitalmars-d-learn
import std.conv; import std.stdio; void main() { double value = -12.000123456; writeln( value.sizeof ); writeln( value ); writeln( value.to!string() ); writeln( value.to!dstring() ); } /* 8 -12.0001 -12.0001 -12.0001 */ In Dart, value.toString() returns "-12.000123456". In