JamesNK / Newtonsoft.Json

Json.NET is a popular high-performance JSON framework for .NET
https://www.newtonsoft.com/json
MIT License
10.73k stars 3.25k forks source link

Use 17 digits of precision with Double.ToString #2823

Open oleks opened 1 year ago

oleks commented 1 year ago

Using 15 digits ("R") leads to failure of roundtrip serialization/deserialization.

See also https://learn.microsoft.com/en-us/dotnet/api/system.double.tostring

Another example is 0.6822871999174

oleks commented 1 year ago

I suppose one could make the argument that it is better to parameterize the library by the format that it should use for Double.ToString, since G17 is also broken, just in a different way.

Serialize(Deserialize<float>("1.1")) != "1.1"

Hence, it is probably best to let the users choose their poison.