Math helper macros. More...
Math helper macros.
Definition in file math.h.
Go to the source code of this file.
#define | SIGNOF(a) |
Returns the sign of a , either -1 or 1. | |
#define | DIV_ROUND(a, b) ((SIGNOF(a) * ((SIGNOF(a) * (a)) + (SIGNOF(b) * (b)) / 2) / (b))) |
Calculates a/ b with arithmetic rounding (.5 away from zero) | |
#define | DIV_ROUND_UP(a, b) |
Calculates a/ b , always rounding up (towards positive infinity) | |
#define | DIV_ROUND_INF(a, b) (SIGNOF(a) * (((SIGNOF(a) * (a)) + (SIGNOF(b) * (b)) - 1) / (b))) |
Calculates a/ b , always rounding away from zero (towards positive and negative inf) | |
#define | MATH_ALIGN(num, chunk) ((chunk) * DIV_ROUND_INF(num, chunk)) |
Align num with the next multiple of chunk . | |
#define DIV_ROUND_UP | ( | a, | |
b | |||
) |
Calculates a/
b
, always rounding up (towards positive infinity)
#define MATH_ALIGN | ( | num, | |
chunk | |||
) | ((chunk) * DIV_ROUND_INF(num, chunk)) |