[Mono-bugs] [Bug 72259][Nor] New - Numerical calculation in Mono produces wrong results

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Sun, 6 Feb 2005 07:55:50 -0500 (EST)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by dcasper@uci.edu.

http://bugzilla.ximian.com/show_bug.cgi?id=72259

--- shadow/72259	2005-02-06 07:55:50.000000000 -0500
+++ shadow/72259.tmp.27491	2005-02-06 07:55:50.000000000 -0500
@@ -0,0 +1,97 @@
+Bug#: 72259
+Product: Mono: Runtime
+Version: 1.1
+OS: 
+OS Details: Fedora 3, VirtualPC
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: dcasper@uci.edu               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Numerical calculation in Mono produces wrong results
+
+Description of Problem:
+
+A numerical computation-intensive console application (class library +
+Main) compiled with mcs produces incorrect results when interpreted in
+Mono.  The same assemblies compiled by mcs, when copied to Windows and run
+under the Microsoft .NET runtime, produce the correct result. 
+
+Steps to reproduce the problem:
+1. mcs /out:OscillatorLibrary.dll /target:library -g Complex.cs
+ComplexMatrix.cs EarthDensity.cs OscillatorEngine.cs
+
+2. mcs /out:OscConsole.exe /r:OscillatorLibrary.dll -g OscConsole.cs
+
+3. mint OscConsole.exe 3000.0 0.95
+
+(These steps are only useful if I figure out how to attach the files in
+question...)
+
+Actual Results:
+(in Mono):
+0.130103895414964 0.455073752325452 0.414822352259584
+0.000465872691053415 0.468309206527928 0.531224920781019
+0.869430231893982 0.0766170411466204 0.0539527269593973
+0.130103895414964 0.455073752325452 0.414822352259584
+0.000465872691053415 0.468309206527928 0.531224920781019
+0.869430231893982 0.0766170411466204 0.0539527269593973
+0.130103895414964 0.455073752325452 0.414822352259584
+0.000465872691053415 0.468309206527928 0.531224920781019
+0.869430231893982 0.0766170411466204 0.0539527269593973
+
+(same mcs-generated JIT files run on Windows):
+0.999999794042912 1.02978543918838E-07 1.02978543918839E-07
+
+1.02978543918839E-07 0.999678772980781 0.000321124040672646
+
+1.02978543918839E-07 0.000321124040672646 0.999678772980782
+
+0.999999794042913 1.02978543352179E-07 1.0297854335218E-07
+
+1.02978543352179E-07 0.999678772980828 0.000321124040626778
+
+1.02978543352179E-07 0.000321124040626778 0.999678772980829
+
+0.999999794042912 1.02978543723565E-07 1.02978543723566E-07
+
+1.02978543723565E-07 0.999678772980805 0.000321124040649712
+
+1.02978543723565E-07 0.000321124040649712 0.999678772980805
+
+
+Expected Results:
+The results above generated on Windows are the expected results.
+
+How often does this happen? 
+Always.
+
+Additional Information:
+
+Since the mcs-compiled JIT files produce the correct answer on Windows,
+with the Microsoft .NET framework installed, the most natural hypothesis is
+that the mono runtime is causing the problem, rather than the compiler.  
+
+The console application involves fairly complicated math, and it is not
+easy to determine at what point the numerical results get screwed up.  I
+created a class to represent complex numbers, and another class to
+represent matrices of complex numbers, including overrides for various
+numerical operators (+,-,*,/, etc).  The application relies heavily on
+calls to System.Math.
+
+My code from Windows (which works fine there) would only run in Mono after
+I recompiled it to break one complicated expression involving operator
+overrides into smaller pieces.  It appeared that an intermediate result
+(reference type) was being lost somehow.  I tried simplifying other,
+similar expressions, but it doesn't fix this problem.  Since the compiled
+code works on Windows, it would appear the compiler is not the problem.
+
+I do not see the link mentioned to add an attachment; if it doesn't appear
+after I click "Commit", I can provide the source code and compiled JIT
+files by email on request.