Bug 4946 - Floating point constants incorrect on Windows
Summary: Floating point constants incorrect on Windows
Status: RESOLVED FIXED
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2012-05-08 14:26 UTC by Jonathan Chambers
Modified: 2012-05-09 17:34 UTC (History)
1 user (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Test case (279 bytes, application/octet-stream)
2012-05-08 14:26 UTC, Jonathan Chambers
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Jonathan Chambers 2012-05-08 14:26:21 UTC
Created attachment 1827 [details]
Test case

Run the attached sample program.

Output *compiled* with OSX or .Net:
False
-9.809089E-45

Output *compiled* with gmcs on Windows:
True
NaN

Error seems to be captured in this IL diff between the two assemblies:

@@ -38,13 +38,13 @@
     // Code size       46 (0x2e)
     .maxstack  8
     IL_0000:  ldstr      "{0}"
-    IL_0005:  ldc.r4     -9.8090893e-045
+    IL_0005:  ldc.r4     (FB FF FF 7F)
     IL_000a:  call       bool [mscorlib]System.Single::IsNaN(float32)
     IL_000f:  box        [mscorlib]System.Boolean
     IL_0014:  call       void [mscorlib]System.Console::WriteLine(string,
                                                                   object)
     IL_0019:  ldstr      "{0}"
-    IL_001e:  ldc.r4     -9.8090893e-045
+    IL_001e:  ldc.r4     (FB FF FF 7F)
     IL_0023:  box        [mscorlib]System.Single
     IL_0028:  call       void [mscorlib]System.Console::WriteLine(string,
                                                                   object)
Comment 1 Jonathan Chambers 2012-05-09 17:34:50 UTC
Fixed by changing preprocessor checks in mono_strtod. In commit 9c17da304c13babe86538b1db307d2640265771d