0与-0

编译器:Microsoft Visal studio C++6.0

代码段内容:

union Def_float
{

    float value;

    struct 

    {
    BYTE by_0; // 最低字节 
    BYTE by_1;
    BYTE by_2;
    BYTE by_3; // 最高字节
   };
};

Def_float temp;
temp.value = atof("0");
CString strT;
strT.Format("%X",temp.by_3);
AfxMessageBox(strT);  // 输出 00

 

temp.value = atof("-0");
strT.Format("%X",temp.by_3);
AfxMessageBox(strT); //输出 80

Def_float temp2;
temp2.value = -0;
strT.Format("%X",temp2.by_3);
AfxMessageBox(strT); //输出 00

 

 

posted on 2012-11-07 13:17  雁北  阅读(209)  评论(0编辑  收藏  举报

导航