Closed
Description
The documentation for numeric format strings says that the G17 format specifier is the recommended way for round-tripping double values, but it doesn't always work. Here is the full example of one such case:
using System;
namespace Roundtripping
{
public class Program
{
public static void Main(string[] args)
{
var s = "23723333333333333433333337";
double d1 = Double.Parse(s);
double d2 = Double.Parse(d1.ToString("G17"));
Console.WriteLine(d1 == d2);
}
}
}
This program prints false on .NET Core 2.2.104, and true on .NET Core 3.0.100-preview-010184. I see that there were a lot of issues and commits fixing the R specifier, but I was under the impression that G17 was always supposed to work.
Found via SharpFuzz.