# Negative infinitive float (-1.#IND00)

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

## Recommended Posts

Hmm... sometimes I get this number: -1.#IND00. I've searched the net and found that it is because the fpu registers aren't cleared before using floats/doubles, is this true? Also, how can I fix this problem, I'm using Dev-C++ and I've got lots of code, so I won't be placing it alle here, but a small piece (a, angle.x and angle.y are floats):
a = (float)atan((double)(LOWORD(lParam) - 120) / (double)(HIWORD(lParam) - 480)) + 1.570796;
angle.x = cos(a);
angle.y = sin(a);


I use the sin, cos and atan functions with floats as parameters and as return values, maybe I should use doubles instead? I've never gotten this error before, so I'm not quite sure how to fix it, besides looking the asm code through and placing emms where it's neccesary. I would much rather have GCC to make the proper arrangement of my code. I've also tried all the optimization levels but none of them seems to be having an effect. Does anyone have a soloution to fix my problem?

##### Share on other sites
I usually end up with that number (or similar other numbers) because of invalid mathematical operations, such as dividing by zero, tangent of pi/2, square root of a negative, etc. Check your math carefully, and make sure you're not doing anything like that.

For example, in your code snippet, if HIWORD(lParam) is 480, then you're probably gonna run into trouble with a division by zero.[/edit]

##### Share on other sites
Quote:
 Original post by AgonyI usually end up with that number (or similar other numbers) because of invalid mathematical operations, such as dividing by zero, tangent of pi/2, square root of a negative, etc. Check your math carefully, and make sure you're not doing anything like that.For example, in your code snippet, if HIWORD(lParam) is 480, then you're probably gonna run into trouble with a division by zero.[/edit]

Thanks, I knew about floating point errors, but I didn't knew that a division with zero or anther illegal operation can cause that. I thought it was a unique problem...
I take sqrt another place in my code, maybe that's the problem. I just multiply with -1 if it's negative now, then I shouldn't be encountering the problem any more, I hope...
The HIWORD(lParam) cannot exceed 479 (minus the titlebar), so that's not the problem, but I think it's solved now.
Else I just have to look for more floating point errors...

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 11
• 10
• 9
• 15
• 22