[ODE] Cross-platform woes

Charlie Garrett charlie.garrett at gmail.com
Mon Aug 22 00:07:34 MST 2005

I think your example program is suffering from the Intel 80-bit
precision feature.  The /Op option for Visual C++ says:

"With /Op, the compiler loads data from memory prior to each
floating-point operation and, if assignment occurs, writes the results
back to memory upon completion. Loading the data prior to each
operation guarantees that the data does not retain any significance
greater than the capacity of its type."

Since the example doesn't assign the intermediate results, no
reduction to single-precision occurs.  If you keep the /Op option and
change the code to:

    float x = b[1]*c[2];
    float y = b[2]*c[1];

    float f1 = x - y;

I believe you will see the same outcome on PC and Mac.

Also, note that if you don't use the /Op option and do use the changed
code with x and y, then VC++ gives you different answers in debug and
release mode.  This is the more common way of seeing Intel's extra
floating point precision.

I'm sorry that I didn't notice the requirement for assignment in
source code before, because the compiler option is not useful for
someone who just wants to compile a library without changing the
source code.


More information about the ODE mailing list