abs

#define abs(x) ((x)>0?(x):-(x))

This macro takes the absolute value of a number.

Usage:

int a = 3;
int b = -25;

int c = abs(a);	//c is 3
int d = abd(b);	//d is 25

Related Posts