Search EggHeadCafe's Job Board
EggHeadCafe Silverlight WPF ASP.NET VB.NET C# Excel SQL Server SharePoint
search
.NET Framework GroupsView
.NET Distributed_Apps
.NET
.NET ADO.NET
.NET ASP.NET
.NET ASP.NET Security
.NET ASP.NET Webcontrols
.NET ASP.NET Web Services
.NET Clr
.NET Compact Framework
.NET Drawing
.NET Interop
.NET Performance
.NET Web Services
.NET Windows Forms
.NET Windows Forms Controls
.NET General
.NET Csharp
.NET Visual Basic
.NET Vc
.NET Security
.NET Xml
Vsnet Debugging
Xml
Xsl
Scripting Jscript
Scripting Visual Basicscript
Scripting Wsh
Smartphone Developer
Visual Basic Com
Visual Basic Controls
Visual Basic Crystal
Visual Basic Database Ado
Visual Basic Syntax
Visual Basic Winapi
Vc Atl
Vc Debugger
Vc Language
Vc Mfc
Vc Stl
Visio Developer Visual Basica
Windowsce Embedded Vc
Windows Powershell
Visual Basic Vista Compatibility
Deployment Server
.NET Micro Porting

Group SummariesView
.NET Framework
Access
BizTalk
Certifications
CRM
DDK
Exchange Server
FoxPro
French
French .NET
Games
German
German .NET
Graphic Design
IIS
Internet
ISA Server
Italian
Italian .NET
Maps
MCIS
Miscellaneous
Mobile Apps
Money
MSN
Networking
Office
Ops Mgr
Publisher
Security
SharePoint
Small Business
Spanish
Spanish .NET
SQL Server
Systems Management Server
Transaction Server
Virtual PC / Virtual Server
Visual Studio
Win32
Windows 2000
Windows 2003 Server
Windows 7
Windows Live
Windows Media
Windows Update
Windows Vista
Windows XP
 

View All Microsoft NET Csharp Posts  Ask A New Question 

C# definition for NAN (in Reflector) is not correct?

Jon Skeet [C# MVP] posted on Wednesday, June 18, 2008 4: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
reply

 

C# definition for NAN (in Reflector) is not correct?

josephbubb posted on Friday, June 20, 2008 3: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.
reply