Posted By

fabioperez on 02/19/11


Tagged

math c define


Versions (?)

Math defines


 / Published in: C
 

  1. /***** MATH *****/
  2.  
  3. /* #define MIN(a, b) (((a) < (b)) ? (a) : (b)) */
  4. #define MIN(a,b) (((a) < (b)) ? (a) : (b))
  5.  
  6. /* Calculates the maximum of a and b. */
  7. #define MAX(a, b) (((a) > (b)) ? (a) : (b))
  8.  
  9. /* Calculates the absolute value of a. */
  10. #define ABS(a) (((a) < 0) ? -(a) : (a))
  11.  
  12. /* Ensures that x is between the limits set by low and high.
  13.   If low is greater than high the result is undefined.*/
  14. #define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))

Report this snippet  

You need to login to post a comment.