Jump to content
  • Advertisement
Sign in to follow this  
nife

Negative infinitive float (-1.#IND00)

This topic is 5151 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

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 this post


Link to post
Share on other sites
Advertisement
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.

[edit]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 this post


Link to post
Share on other sites
Quote:
Original post by Agony
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.

[edit]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...

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!