Jump to content
  • Advertisement
Sign in to follow this  
billconan

a -1.#IND problem

This topic is 3677 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!