I want to detect an overflow (or underfolow) floating point
calculation. Do you know how?
I figure out a way below but it just partly works (only for
SW_ZERODIVIDE events). In the code below, d2 is apparently overflow.
But ui gets a value of zero instead of _SW_OVERFLOW (0x00000004) when
I debug the code. If I change d1 to 0., then ui is _SW_ZERODIVIDE
(0x00000008) as desired. Do you know why? Thanks for any advise.
double d1 = 100.;
double d2 = DBL_MAX * d1;
unsigned int ui = _statusfp();
if (ui > 1)
// handle the error