Sign in to follow this  
billconan

a -1.#IND problem

Recommended Posts

hello guys, my program crashes, because some of the floats have a value of -1.#IND i know it is a symbol for infinity and probably caused by overflow. but my question is how to debug this error. i want to add some lines in the code like: if(value==-1.#IND) ... therefore, i can identify the location where the wrong value is computed. however, it seems that the compiler i'm using, which is visual studio 2008, doesn't recognize "-1.#IND" so i don't know how to do this. please help. thank you very much.

Share this post


Link to post
Share on other sites
Quote:
Original post by RealMarkP
You can try the following functions from the math.h header. But in reality, you should be checking your math so that it doesn't divide by zero (or something similar).


thank you. i'm not sure if the problem was caused by a division by zero. i need to identify the location of the problem. thank you.

Share this post


Link to post
Share on other sites
There's a way to check for invalid numbers. It looks strange, but it does work:

if (x != x)
{
...
}

I remember I once had a very simillar problem, it was caused by acosf and floating point imprecision. I was giving acosf value 1.0000000001f and it returned -1.#IND. To fix it, I simply clamped the input to acosf to the range [0;1].

Share this post


Link to post
Share on other sites
Quote:
Original post by Giedrius
There's a way to check for invalid numbers. It looks strange, but it does work:

if (x != x)
{
...
}

I remember I once had a very simillar problem, it was caused by acosf and floating point imprecision. I was giving acosf value 1.0000000001f and it returned -1.#IND. To fix it, I simply clamped the input to acosf to the range [0;1].



i do use acosf, and maybe that is also my problem.

thank you.

and for some reason, there is no isinf function in my math.h

i see this:

#if defined(_M_AMD64)
_CRTIMP int __cdecl _isnanf(_In_ float _X);
#endif /* _M_AMD64 */

this is odd. only amd64 needs check "not a number"?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this