[Mono-list] Mono and .Net Floating Point Inconsistencies

ddambro ddambro at gmail.com
Fri Jan 16 23:19:52 EST 2009

The code is compiled for x86 in Windows, and the problems I describe persist
even using mono for Windows.  That is, on every computer I've tried so far
regardless of OS and processor type, all of the mono runs produce the same
results and all of the .NET runs produce the same results, but these results
are different from each other.  This includes a 64-bit Vista machine running
the x86 code in .NET and mono (installed as x86).  How would this affect
your suggested fix?  Also I noticed a fairly significant speed up when I
converted all my doubles to floats in this code a few years ago, would your
fix undo that?  mono already runs the code MUCH slower than .NET so I'd hate
to get another performance hit.

Dallman, John-2 wrote:
>> when I take the same binary and run it with the same inputs it 
>> produces different outputs if it is run on mono and .Net.
> This is with Mono on Linux, and .NET on Windows? The executable 
> is 32-bit .NET code? 
> I suspect that you've hit a misfeature that exists for most 
> floating-point code on 32-bit x86 Linux.
> The code to be run in the C function is:
> #include <fpu_control.h>    /* Mask the Denormal, Underflow and Inexact
> exceptions,
>         				leaving Invalid, Overflow and
> Zero-divide active.
> 				      Set precision to standard doubles,
> and round-to-nearest. */    
> fpu_control_t desired = _FPU_MASK_DM | _FPU_MASK_UM | _FPU_MASK_PM |
> _FPU_SETCW( desired);
> This needs to be a C function because everything in uppercase in 
> that code is a macro, from fpu_control.h. You may want to leave out 
> enabling floating point traps, in which case the code becomes:
> #include <fpu_control.h>    /* Set precision to standard doubles, and
> round-to-nearest. */    
> fpu_control_t desired =	_FPU_DOUBLE | _FPU_RC_NEAREST ;    
> _FPU_SETCW( desired);
> It would be good, really, if Mono had a standard call for setting 
> up consistent floating-point on all its platforms. 
> -- 
> John Dallman
> Parasolid Porting Engineer
> Siemens PLM Software
> 46 Regent Street, Cambridge, CB2 1DP
> United Kingdom
> Tel: +44-1223-371554
> john.dallman at siemens.com
> www.siemens.com/plm
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list

View this message in context: http://www.nabble.com/Mono-and-.Net-Floating-Point-Inconsistencies-tp21428695p21512975.html
Sent from the Mono - General mailing list archive at Nabble.com.

More information about the Mono-list mailing list