Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# fails to parse NaN as a double

On a Windows PC in Japan, this line of C# throws a format exception:

double d = double.Parse("NaN");

This line executes fine on my PC in the U.S.

Don't know where to begin troubleshooting this one. Any thoughts?

Thanks in advance, Jim

like image 336
Jim C Avatar asked Oct 15 '22 03:10

Jim C


1 Answers

I see what the problem is. Try using the invariant format provider.

double d = double.Parse("NaN", CultureInfo.InvariantCulture);
like image 81
ChaosPandion Avatar answered Oct 20 '22 21:10

ChaosPandion