I am confused about why the following #define
macros are not evaluating as expected when used in the following if statement:
#define kOffsetX 2048.0
#define kPositionX (screenSize.width * (kOffsetX/2048.0))-10.0
CGSize screenSize = [CCDirector sharedDirector].winSize;
float potentialPosition = 486.86f;
float playersFieldOffset = 1.0;
if ((potentialPosition - kPositionX) * playersFieldOffset > 0.0) {
Note that kPositionX evaluates to 470.0. The if statement evaluates to FALSE when clearly 486-470 is greater than zero. However, if I put parenthesis around kPositionX, then the if statement properly evaluates to TRUE.
Why is this happening? Is this an improper way to use a #define
? If so, what should I be doing?