Tag:

当任何数学运算在.net 4中产生’NaN’时,如何强制C#编译器抛出exception?

我有一个很复杂的源代码,我需要找到变量值设置为nan的确切位置。 所以我需要编译器在那时抛出一个exception。 之前已经问过这个问题。 我发现以下答案是一个很好的答案。 此代码在.net 3.5中运行良好。但是当我使用.net 4时,此解决方案无法正常工作。 即使我在调试器中启用“抛出exception时中断”,也无法在代码中找到exception。 任何的想法? using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Runtime.InteropServices; namespace ConsoleApplication2 { class Program { [System.Runtime.InteropServices.DllImport(“msvcrt.dll”)] public static extern uint _control87(uint a, uint b); [System.Runtime.InteropServices.DllImport(“msvcrt.dll”)] public static extern uint _clearfp(); static void Main(string[] args) { float zero = 0.0f – args.Length; // Want […]

NaN对双打意味着什么?

NaN和Infinity什么区别? NaN何时出现? 它是什么?