# 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.

## 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 on other sites
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).

##### Share on other sites
Quote:
 Original post by RealMarkPYou 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 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 on other sites
Quote:
 Original post by GiedriusThere'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"?

1. 1
2. 2
Rutin
19
3. 3
khawk
18
4. 4
A4L
14
5. 5

• 12
• 16
• 26
• 10
• 44
• ### Forum Statistics

• Total Topics
633767
• Total Posts
3013734
×