Skip to content

Instantly share code, notes, and snippets.

@alvaromuir
Created January 5, 2014 17:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alvaromuir/8270884 to your computer and use it in GitHub Desktop.
Save alvaromuir/8270884 to your computer and use it in GitHub Desktop.
Some common Objective-C Macros
#define PI 3.141592654
#define TWO_PI 2.0 * PI
#define SQUARE(x) ((x)*(x))
#define CUBE(x) ((x)*(x)*(x))
#define IS_LEAP_YEAR(y) y % 4 == 0 && y % 100 != 0 || y % 400 == 0
#define IS_LOWER_CASE(x) ( ((x) >= 'a') && ((x) <= 'z'))
#define TO_UPPER(x) (IS_LOWER_CASE(x) ? (x) - 'a' + 'A': (x))
#define INCHES_PER_CENT 0.394
#define CENT_PER_INCH (1/INCHES_PER_CENT)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment