Why are the return values of these doubles -1.#IND?

前端 未结 3 1058
星月不相逢
星月不相逢 2020-12-01 23:32

I have :

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

There are v

相关标签:
3条回答
  • 2020-12-02 00:10
    std::cout << (0/0.f);
    // Output: -1.#IND
    

    It's NaN.

    0 讨论(0)
  • 2020-12-02 00:17

    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 displays a NaN as -1.#IND ("IND" for "indeterminate") while Linux displays 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.

    0 讨论(0)
  • 2020-12-02 00:28

    In my experience -1.#IND comes from imaginary numbers. So, doing cout << sqrt(-1.); should output -1.#IND

    0 讨论(0)
提交回复
热议问题