#define negative numbers?

c-preprocessor, ios, objective-c, xcode

Solution

Did you try it? It should work fine.

However, I would encourage you to not use pre-processor macros, but instead use real constants.

static const float kGravity = -9.8f;

Preprocessor directives are a bit frowned upon, in general. Here's some more info on the subject: #define vs const in Objective-C

Problem

Simple question, but I cannot seem to find the answer. Is it okay to use `#define` to define a negative number, as in: ``` #define kGravity -9.8 ``` XCode is changing the 9.8 to the color of my numbers I have set (purple), but the `-` is being shown as the same color as the define statement (orange). Is this legal? Will it compile?

Original source