Code 1.
using System;
class P
{
static void Main()
{
double d = 1.23456;
Console.WriteLine(d);
}
}
Code 2.
using System;
class P
{
static void Main()
{
double d = 1.23456;
Console.WriteLine(d);
}
}
Can you find difference between two?
Yes,It was JUST line feed. And,these two code lead to a different result.
Result 1.1,23456
Result 2.1.23456
It seems '.' replaced by ','.
The same problem occurs in Mono.
I highly recommend to use substitute methods like this:
static string doubleToString(double d)
{
int s = (int)d;
string a = Convert.ToInt32((d - s) * 1000000000).ToString().PadLeft(9, '0');
return $"{s}.{a}";
}
edit. This issue is not a bug. Thank you for teaching me AlexDmitriev, Gassa.
This is locale problem. I am using "Ja" locale, but I should use "en_US" locale.