.NET Framework - C# definition for NAN (in Reflector) is not correct?

Asked By josephbubb
20-Jun-08 03:52 AM
Greetings,

Question about how the NaN constant is defined in .NET.

When I look at the C# definition for the System.Double NaN definition
in Roeder's Reflector, it looks like this:

public const double NaN = (double) 1.0 / (double) 0.0;

However, according to the .NET documentation (and the IEEE standard),
the actual definition is the result of dividing zero by zero (0/0).
Dividing 1/0 is positive infinity.

Interestingly, when I switch to the any other decompilation languages
(ex. Visual Basic, or Managed C++), the value of NaN is not
specifically defined as a division, but instead uses a constant.  For
example, Visual Basic looks like this:

Public Const NaN As Double = NaN



Is this simply a bug in Reflector for C#, or am I missing something?

Thanks in advance.

By the way, I'm using Reflector version 5.1.2.0 and pointing to
the .Net framework version 2.0.50727.1433.
System.Double
(1)
Visual
(1)
Reflector
(1)
IEEE
(1)
NAN
(1)
  Jon Skeet [C# MVP] replied...
18-Jun-08 04:46 PM
Looks like a reflector bug to me.

--
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
help
MarshalAs(UnmanagedType.I4)]System.Int32 nCons, [MarshalAs(UnmanagedType.I4)]System.Int32 units, [MarshalAs(UnmanagedType.R8)]System.Double density, [MarshalAs(UnmanagedType.R8)]System.Double fvf, [MarshalAs(UnmanagedType.LPArray)]System.Double[] cProperties, [MarshalAs(UnmanagedType.LPArray)]System.Double[] fProperties, [MarshalAs(UnmanagedType.LPArray)]System.Double[] mProperties, [MarshalAs(UnmanagedType.LPArray)]System.Double[, ] strC, [MarshalAs(UnmanagedType
Is Visual Studio self-hosting ? .NET Framework Does Microsoft use Visual Studio IDE, Visual Studio Debugger, Visual Studio Linker and Visual Studio compiler for developing Visual Studio ? Or is Visual Studio not good enough for them and are they in fact using something else ? Visual Studio Development Discussions Visual Studio (1) Linker (1) Don't spread it around but they
i -> $Value [$($Value.gettype().fullname)]"} I get the results: 0 -> 1 [System.Int32] 1 -> 2 [System.Double] 2 -> 4 [System.Double] 3 -> 8 [System.Double] 4 -> 16 [System.Double] 5 -> 32 [System.Double] When I execute the type conversion of the output of [Math
Visual Studio vs Visual Web Developer .NET Framework Hi! The Visual Web Developer is better than Visual Studio 2005 for web development? All the Ajax examples are developed in Visual Web Developer. Thanks ASP.NET Discussions Visual Studio 2005 (1) Visual Studio (1) Office (1) Compiler (1) Library (1) Control (1) Coverage (1) Database (1) I think you're confusing the products here. Visual Web Developer IS the web design portion of Visual Studio. Visual Studio includes a number