[Clp] patch for Visual C++ floating-point model problem
William H. Patton
pattonwh at comcast.net
Sun Aug 10 15:37:35 EDT 2008
I think your fix is fine.
The basic issue is ancient. Do not compare floats without a precision guard.
I am sure I was taught this in 1964 FORTRAN II and of course later in Knuth
books.
http://ftp1.us.proftpd.org/pub/languages/fortran/ch1-8.html#02
Here is famous 5 year effort for 7 lines of code to address tis in the
1970's
http://wwwvms.mppmu.mpg.de/vmssig/src/FOR/FUZZLOOP.FOR
http://ftp.cac.psu.edu/pub/ger/fortran/hdk/eps.f90
http://tcllib.sourceforge.net/doc/fuzzy.html
I suppose this means CLP source should be scanned for other occurrences
of real :compare: real. This sounds hard without parser support.
Maybe some C++ header with overloading of the compares for real types could
generate an explicit function reference. Then the assembly listings could be
scanned.
William
-----Original Message-----
From: clp-bounces at list.coin-or.org [mailto:clp-bounces at list.coin-or.org] On
Behalf Of Arno Schödl
Sent: Sunday, August 10, 2008 11:10 AM
To: Michael Hennebry
Cc: clp at list.coin-or.org
Subject: Re: [Clp] patch for Visual C++ floating-point model problem
MSVC does not support long doubles:
http://msdn.microsoft.com/en-us/library/d0we956d(VS.80).aspx
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.
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.
C99 might be different.
--
Michael hennebry at web.cs.ndsu.NoDak.edu
"Those parts of the system that you can hit with a hammer (not advised)
are called Hardware; those program instructions that you can only
curse at are called Software."
--
Dr. Arno Schoedl · aschoedl at think-cell.com
Technical Director
think-cell Software GmbH · Invalidenstr. 34 · 10115 Berlin, Germany
http://www.think-cell.com · phone +49-30-666473-10 · fax +49-30-666473-19
Geschäftsführer: Dr. Markus Hannebauer, Dr. Arno Schoedl · Amtsgericht
Charlottenburg, HRB 85229
_______________________________________________
Clp mailing list
Clp at list.coin-or.org
http://list.coin-or.org/mailman/listinfo/clp
More information about the Clp
mailing list