different debug-release results 
Author Message
 different debug-release results

Hello Fellows,

first I found (Feb. 5 2001 4:27 AM an my own "reply" at 5:28 AM) different
results in the debug an release-version of a simple VC++ 6.0 program using the sin
(x)-function.
Dave Oldroyd remarked that the leading 14 decimal digits were the same, so what?

Well, I think that the result of a double precision calculation should always be
the same IN ALL 64 BITs of the variable.
I digged a bit deeper and found out that the reason for the difference of the sin
(x)-function is in fact a difference in the addition and / or division before.

Example code:

union _U {double d; unsigned char u[8]; };

int main (int argc, char **argv)
{
        long i;
        double x=0.89552;
        long errl[]={1271,2002,2135};   // -> {2.16652,2.89752,3.03052};
        _U U;

#ifdef _DEBUG
        fprintf(stderr,"DEBUG:\n");
#else
        fprintf(stderr,"RELEASE:\n");
#endif

        for (i=0; i < 3; i++) {
                U.d=x+errl[i]/1000.0;
                fprintf(stderr,"sin(%7.5f)=..........%02x%02x%02x\n",
                        U.d,U.u[2],U.u[1],U.u[0]);
        }

        return 0;

Quote:
}

the result is:

DEBUG:
sin(2.16652)=..........110a13
sin(2.89752)=..........3c0c1f
sin(3.03052)=..........0efdc9
RELEASE:
sin(2.16652)=..........110a14
sin(2.89752)=..........3c0c20
sin(3.03052)=..........0efdca

you see: two times Bit 0, one time Bit 1 is different.
If you calculate sin(x) from these values, you will get differences in up to 9
bits.

As I said, I hadn't expected this behavior and consider it a bug.

So long, Mic.



Sat, 26 Jul 2003 18:05:28 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. different results between Debug/Release builds

2. sin(x) different debug&release-results

3. results are different in debug and release

4. Different results between Debug and Release

5. Results can change between Debug and Release mode?

6. ATL7 / different OSs == different results

7. Different results of OpenSchema() with different drivers?

8. Different results when using different optimization options

9. For help: under different OS has different compile result

10. different machines different results

11. For help: different OS has different compile result

12. Structure is different in debug/release

 

 
Powered by phpBB® Forum Software