【C#】Sometime double.ToString() returns Weird value

Правка en1, от keymoon, 2017-12-30 00:35:48

33789158 33791469 difference between two submissions

In first submission,I use implicit conversion:double to string.As a result,It was WA.Output is:

2 6 9,87298334620742 13,3370849613452 12,518734657272 13,3370849613452

Next,I decide 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}";
}

and it was AC.

So obviously,

Теги c#, issues, locale, mono, ms

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en6 Английский keymoon 2017-12-30 03:01:27 199
en5 Английский keymoon 2017-12-30 01:02:25 0 (published)
en4 Английский keymoon 2017-12-30 00:58:41 6
en3 Английский keymoon 2017-12-30 00:57:55 12
en2 Английский keymoon 2017-12-30 00:57:30 777
en1 Английский keymoon 2017-12-30 00:35:48 670 Initial revision (saved to drafts)