有以下代码
double tempvalue=0.0;
for (int row2=0; row2<N1;row2++)
{
tempvalue+=ClassNormalMatrix[row2][col1]*ClassNormalMatrix[row2][col1];
}
tempvalue=sqrt(tempvalue);调试窗口看到:tempvalue  1.#INF000000000是怎么回事,是不是溢出了?
我要取整怎么做?
请高手指点

解决方案 »

  1.   

    The sqrt function returns the square-root of x. If x is negative, sqrt returns an indefinite (same as a quiet NaN). You can modify error handling with _matherr.
    取整:强制类型转换double tempvalue=4.8;
    int nValue = (int)tempvalue;现在nValue等与4
      

  2.   

    试一下:
    double dbg_fTemp = sqrt (-1.0);
      

  3.   

    我这里tempvalue 不可能是负数,因为它是平方和
    我不知道:“1.#INF000000000”是什么东西,它的值怎么会变成这个东西
      

  4.   

    那你试一下:
    double dbg_fTemp  = sqrt (-1.0) * sqrt (-1.0);
    double dbg_fTemp2 = sqrt (dbg_fTemp);
      

  5.   

    “1.#INF000000000”(还有“-1.#INF000000000”)反正就是无意义的意思啦,你还想叫我怎么说呢
    [这是ANSI C 中的概念,标准C中凡是有该值参与的运算都,其值会为1.#INF000000000]