-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Labels
Milestone
Description
While doing some mathematical stuff that worked fine in Java I found that C# / .NET does a rather poor job on parsing double values:
Number2Parse=4.3413853813852797e+192 IEEE754=67ee7316b1545878 C#=4.3413853813852797E+192
Number2Parse=4.34138538138528e+192 IEEE754=67ee7316b1545878 C#=4.3413853813852797E+192
You can verify in any browser that 4.3413853813852797e+192 and 4.34138538138528e+192 are distinct values. Version: CLR v4.0.30319
using System;
namespace mathbug
{
class Program
{
static void ShowNumber(string number2Parse)
{
double d = Double.Parse(number2Parse);
ulong ieee754 = (ulong)BitConverter.DoubleToInt64Bits(d);
Console.WriteLine("Number2Parse=" + number2Parse + " IEEE754=" + Convert.ToString((long)ieee754, 16) + " C#=" + d.ToString("G17"));
}
static void Main(string[] args)
{
ShowNumber("4.3413853813852797e+192");
ShowNumber("4.34138538138528e+192");
}
}
}