当使用“Double.NaN”时,奇怪的错误和“double.MaxValue”。在c# [英] Strange error when using "Double.NaN" and "double.MaxValue" in c#
问题描述
我在我的代码中有一个函数像(C#,NET 3.5,Visual Studio 2008):
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();
...
虽然看起来不可思议(对我来说是) (WinXP SP3),如果我使用别名(double.NaN或double.MaxValue)程序是破碎的没有任何类型的(#)强的>只有
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.
我的意思是:
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.
推荐答案
好,我发现问题:
- 我安装了.NET 4.0,但程序需要NET 3.5。我安装了NET 3.5,它工作。
真的,我见过最罕见的东西。
Really, that rarest thing, i have ever seen.
感谢大家的回应。
这篇关于当使用“Double.NaN”时,奇怪的错误和“double.MaxValue”。在c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!