为什么这些双打的返回值是-1.#IND?

为什么这些双打的返回值是-1.#IND?

问题描述:

我有:

double score = cvMatchContourTrees( CT1, CT2, CV_CONTOUR_TREES_MATCH_I1, 0.0 );
        cout<<score<<endl;

返回的值为-1.#IND.除此之外,正值是正常值,例如1.34543.

There are values returned as -1.#IND. Other than that, the positive values are normal, like 1.34543.

为什么会这样?我该怎么解决?

Why does this happen? How do I solve it?

正如弗雷德里克(Frederic)所说,这是"出色的参考书:

As Frederic says, it's the result of a 'Not a Number' being formatted by an application built with visual studio on windows. John D Cook has an excellent reference:

Windows将NaN显示为-1.#IND("IND"表示不确定"),而Linux显示nan.

Windows displays a NaN as -1.#IND ("IND" for "indeterminate") while Linux displays nan.

...

简而言之,如果得到1.#INF或inf,则查找溢出或被零除.如果得到1.#IND或nan,请查找非法操作.

In short, if you get 1.#INF or inf, look for overflow or division by zero. If you get 1.#IND or nan, look for illegal operations.

如果对字符串进行任何格式的格式化,请当心截断;处理这些问题时,我遇到了相关问题自己的错误.

Watch out for truncations if you do any sort of formatting with your string; I've encountered related issues when handling these sorts of errors myself.