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

Michael Hennebry hennebry at web.cs.ndsu.nodak.edu
Mon Aug 11 10:09:49 EDT 2008


On Mon, 11 Aug 2008, Arno Schödl wrote:

> > IIRC there is a bit in the x86 processors that when flipped will
> > effectively lop 16 bits off the floating point registers.
> > I suspect that flipping that bit would involve writing some assembler.
> > That should solve the problem so long as you don't invoke any library
> > functions that relay on 80-bit floating point.
> > IIRC printf is one of them.
>
> .NET/CLR does not let you change the floating-point environment at all, but still suffers from the x87 problem:
>
> ECMA-335 http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-335.pdf
> Partition I Section 12.1.3

It implies that one shouldn't.
That doesn't mean one can't.

> Calling .NET actually resets the control word in some cases:

Well, don't do that
or change it again.

> http://forums.msdn.microsoft.com/en-US/clr/thread/e45fa265-05d1-4ab4-bd4f-b6f9164ca1ab/
>
> In native code, when programming a DLL, every entry point must set the control word properly and set it back on exit, in case the caller relies on it. Overall, I'd prefer leaving the control word alone.

What about static libraries?

Comparing floating point numbers for equality is rarely a good idea,
but it would still be nice if the same expression with the same data
could be relied on to produce the same value each time.

-- 
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."





More information about the Clp mailing list