Bizarre Conditional Operator Problem in C++
Hi all,
Today I encountered a very strange problem. It appears that the conditional '>' operator is not working correctly in the following code:
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:
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
if (velocity.x() > MAX_VELOCITY_WHILE_RUNNING_ON_GROUND);
remove the semi colon at the end and it should work.
remove the semi colon at the end and it should work.
"When you dream, there are no rules..."
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Bizarre glitch... | vnvrymdreglage | 8 | 3,747 |
Jan 22, 2007 06:14 PM Last Post: vnvrymdreglage |
|
| Bizarre Bug | ferum | 7 | 3,326 |
Jan 20, 2007 03:26 PM Last Post: ferum |
|
| Conditional Compilation Errors | Blacktiger | 8 | 3,070 |
Jun 15, 2006 09:42 PM Last Post: szymczyk |
|

