//print function
CString fmt(double db)
{
CString cs;
cs.Format("%f", db);
return cs;
}
//problem
void TheDlg::Test00()
{
const double dbInf = 1.0/::sin(0); //infinite
const double dbZero = (::fabs(::cos(3.14159/2))<0.9)?0:1; //line 1
CString cs;
cs += fmt(dbZero)+"\\r\\n"; //line 2
cs += fmt(dbZero \* dbInf)+"\\r\\n"; //line 3
cs += fmt(0 \* dbInf)+"\\r\\n"; //line 4
MessageBox(cs);
}
above dbZero only has 2 possible values : 0 or 1 - see line 1; output:
0.000000
-1.#IND00
0.000000
output of line 2 shows that dbZero is zero. output of line 3 shows that dbZero is not zero, since it is different from output of line 4. funny thing is that if change line 1 to:
const double dbZero = (0.1<0.9)?0:1;
Then all outputs are zeros. Why? How to make dbZero as a true zero in problem code?