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
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);
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);
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
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(
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
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