kingofsquirrels
2006.05.23, 06:18 PM
Hi all,
Today I encountered a very strange problem. It appears that the conditional '>' operator is not working correctly in the following code:
if (velocity.x() > MAX_VELOCITY_WHILE_RUNNING_ON_GROUND);
{
printf("(velocity.x = %f) > (max_vel = %f)\n\n", velocity.x(), MAX_VELOCITY_WHILE_RUNNING_ON_GROUND);
velocity.setX(MAX_VELOCITY_WHILE_RUNNING_ON_GROUND );
}
The output of the printf() function is: (velocity.x = -2.666667) > (max_vel = 40.000000).
velocity.x() is an inline function that simply returns a private _x variable. MAX_VELOCITY_WHILE_RUNNING_ON_GROUND is a static const float set to 40.0.
Any ideas what might be causing this? I'm using XCode 2.1 with GCC 4.0.
Thanks!
-- Will
Today I encountered a very strange problem. It appears that the conditional '>' operator is not working correctly in the following code:
if (velocity.x() > MAX_VELOCITY_WHILE_RUNNING_ON_GROUND);
{
printf("(velocity.x = %f) > (max_vel = %f)\n\n", velocity.x(), MAX_VELOCITY_WHILE_RUNNING_ON_GROUND);
velocity.setX(MAX_VELOCITY_WHILE_RUNNING_ON_GROUND );
}
The output of the printf() function is: (velocity.x = -2.666667) > (max_vel = 40.000000).
velocity.x() is an inline function that simply returns a private _x variable. MAX_VELOCITY_WHILE_RUNNING_ON_GROUND is a static const float set to 40.0.
Any ideas what might be causing this? I'm using XCode 2.1 with GCC 4.0.
Thanks!
-- Will