OT: Re: [Insight-users] Not so Silly questions about registration

Luis Ibanez luis.ibanez@kitware.com
Tue, 25 Feb 2003 11:25:50 -0500


Hi Tuhin,


It is hard to believe, isn't it ?  :-)

Here is the example in which Debug and Release
modes in VC 6.0 give different results on trivial
code:

---------------------------------------------
#include <iostream>
int main()
{
    double dv        = 1.9;
    float  fv        = static_cast<float>( dv );
    float  diff      = static_cast<float>( dv ) - fv;
    std::cout << "Diff = " << diff << std::endl;
    return 0;
}
-----------------------------------------------

If you compile this code in "Release" mode the difference
printed out is "0". When the same code is compiled on
"Debug" the result is:  2.38419e-008

You can get around the problem by enabling /Op options
that force the compiler to use IEEE standards for numeric
representation.

The /Za option (ANSI compatibility) turns on /Op by default.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_.2f.op.asp




Regards,


    Luis


-----------------------------------
Tuhin wrote:
>>T=float and T=double will already give different results...
>>
>>and if you use VC++, T=float in debug mode and T=float in
>>release mode will also give different results.
> 
> 
> Luis,  what do you mean by that last statement? is there some documentation 
> that I can read that highlights this subtlety in VC++?
> 
> TIA
> 
> Tuhin
> 
>