Strange difference in string formatting between .NET Core and .NET Framework

Viewed 28

Consider the following simple line of code.

Console.WriteLine((7.9124999999999973).ToString("F3"));
  • In .NET Framework, the result is 7.913.
  • In .NET Core, the result is 7.912.

You can verify the results here.

Why is there a discrepancy? Is it documented anywhere? And is there any way to mimic the behavior of .NET Framework in .NET Core?

0 Answers
Related