Sign in to follow this  
renegade weapon

[SDL] Floating Point Exception

Recommended Posts

I have narrowed the cause of this error down to the following code.
int FindPointOfImpact ()
{
  int slope;
  slope = (ball.y - yimpact) / (ball.x - ximpact);
  return -(ball.y -slope*(ball.x)-bound) / (slope*ball.x);
}  
I'm pretty sure the math is correct... but everytime the function is called, the program crashes.

Share this post


Link to post
Share on other sites
Yeah, check you are not dividing by zero. Also remember you want to return an int:

int FindPointOfImpact ()

{

float slope;

slope = (ball.y - yimpact) / (ball.x - ximpact);

return (int)(-(ball.y -slope*(ball.x)-bound) / (slope*ball.x));

}

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