Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
536 views
in Technique[技术] by (71.8m points)

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

I have :

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

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...