[Clp] patch for Visual C++ floating-point model problem

Matthew Saltzman mjs at clemson.edu
Sun Aug 10 14:58:53 EDT 2008


On Sun, 2008-08-10 at 18:09 +0200, Arno Schödl wrote:
> MSVC does not support long doubles:
> 
> http://msdn.microsoft.com/en-us/library/d0we956d(VS.80).aspx

That's not quite correct--long double is the same as double.  But there
is no way to store the 80-bit register value.  On the other hand, see

        http://msdn.microsoft.com/en-us/library/aa289157(vs.71).aspx

I didn't look to see if it applies to VS8.

> 
> Arno
> 
> -----Original Message-----
> From: Michael Hennebry [mailto:hennebry at web.cs.ndsu.nodak.edu] 
> Sent: Sunday, August 10, 2008 6:02 PM
> To: Arno Schödl
> Cc: clp at list.coin-or.org
> Subject: Re: [Clp] patch for Visual C++ floating-point model problem
> 
> On Sun, 10 Aug 2008, Arno Schödl wrote:
> 
> > With my floating-point model problem, I should have probably asked first which floating point model Clp/COIN assumes. This is the GCC compiler thread referring to the same problem:
> >
> > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=323
> >
> > They apparently decided that GCC by default won't guarantee any rounding, similar to MSVC's /fp:fast. With the GCC -ffloat_store option, behavior is similar to MSVC /fp:precise, forcing rounding to 64 bit on assignments. I did not find this option in the COIN-Clp makefiles, and I do not recommend it because it hurts performance. If there is no other provision made that I overlooked, it seems to me that the current Clp code is incorrect, and something along the lines of my patch would be necessary.
> 
> IIRC neither C89 nor C++ guarantee much about floating point.
> The only guarantees are the definitions of the values in float.h .
> In particluar, x+y is not guaranteed to give the same value twice
> even if x and y are unchanged, even if the value is exactly representable.

Standard C doesn't say much about floating point.  It's the underlying
hardware that matters.  Lots of discussion about the underlying hardware
on Intel/AMD in the gcc bug link above.  Standard C does restrict
optimizations that would alter the outcome of floating-point operations
from "as-written".

> 
> In the x86's, I think that the problem could be worked
> around by either by converting all the doubles to long
> doubles or by using a compiler in which double is 80 bits.

See suggestions in the gcc bug link.

> 
> C99  might be different.

C99 requires IEC 60559 (AKA IEEE 754) if __STDC_IEC_559__ is defined,
and provides functions and pragmas to set control modes, handle
exceptions, view status flags, and control some other aspects of
floating-point behavior.

> 
-- 
                Matthew Saltzman

Clemson University Math Sciences
mjs AT clemson DOT edu
http://www.math.clemson.edu/~mjs




More information about the Clp mailing list