Strange error when using “Double.NaN” and “double.MaxValue” in c#

跟風遠走 提交于 2019-12-24 15:42:58

问题


I have a function in my code like (C#, NET 3.5, Visual Studio 2008):

public double function CalculateSomething()
{
   ...
   double a = double.NaN; // Or double.MaxValue, with same behaviour
   ...
}

This function is called by the main class, like this:

...
double res = o.CalculateSomething();
...

Although it looks like incredible (for me, it is) and ONLY on certain computers (only in 2 computers from 60) without anything special (WinXP SP3), if I use the "alias" (double.NaN or double.MaxValue) the program is broken without any kind of error screen when the program calls "CalculateSomething", whereas if you assign a particular value, works perfectly.

I mean:

public double function CalculateSomething()
{
   ...
   double a = double.NaN; // FAAAAIL!!!!
   double b = -99999; // OK... 
   ...
}

Although the change I made, the program can run on all computers, i have curiosity. Does anyone know what may be happening?. Thank you.


回答1:


Ok, i found the problem:

  • I installed NET 4.0, but the program needed NET 3.5. I installed NET 3.5 and it worked.

Really, that rarest thing, i have ever seen.

Thank you all for your responses.



来源:https://stackoverflow.com/questions/5095116/strange-error-when-using-double-nan-and-double-maxvalue-in-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!