Skip to content

Instantly share code, notes, and snippets.

@ahrvoje
Created April 2, 2016 15:57
Show Gist options
  • Select an option

  • Save ahrvoje/d25c8600d73cb149e978a0989198426c to your computer and use it in GitHub Desktop.

Select an option

Save ahrvoje/d25c8600d73cb149e978a0989198426c to your computer and use it in GitHub Desktop.
// .NET v4.6.1073.0 for x64 target on Windows 10
using System;
namespace NET_double_parse
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("{0:G1}", System.Double.Parse("2.4703282292062325e-324")); // 0 - correct
Console.WriteLine("{0:G1}", System.Double.Parse("2.4703282292062326e-324")); // 5E-324 - should be 0 !!!
Console.WriteLine("{0:G1}", System.Double.Parse("2.4703282292062327e-324")); // 5E-324 - should be 0 !!!
Console.WriteLine("{0:G1}", System.Double.Parse("2.4703282292062328e-324")); // 5E-324 - correct
Console.ReadKey();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment