0

I have a very strange behaviour with the double.TryParse() method.

I have this

double result= -1;
bool ok;
ok = double.TryParse("0,28", out result); // ok=true, result=0.28000000000000003
ok = double.TryParse("0,52", out result); // ok=true, result=0.52000000000000002
ok = double.TryParse("0,44", out result); // ok=true, result=0.44

The CurrentCulture is French, I also tried specifying InvariantCulture, and this didn't solve anything.

I tried the same code in another project, and here it worked well (both WebSite in .NET 4.0). I don't know what is wrong in my project, no special references added, web.config pretty clean ... Any idea ?

4

0 回答 0