Skip to content

Instantly share code, notes, and snippets.

@dbrockman
Created January 22, 2013 16:43
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 dbrockman/4596152 to your computer and use it in GitHub Desktop.
Save dbrockman/4596152 to your computer and use it in GitHub Desktop.
// Takes a number and clamps it to within the provided bounds.
#define Clamp(_num, _min, _max) MIN((_max), MAX((_min), (_num)))
// Check if the two floats are equal.
#define FloatEqual(A, B) (ABS((A) - (B)) < FLT_EPSILON)
// Check if the two floats are NOT equal.
#define FloatNotEqual(A, B) (ABS((A) - (B)) > FLT_EPSILON)
// Check if the float is equal to zero.
#define FloatIsZero(A) (ABS(A) < FLT_EPSILON)
// Check if the float is NOT equal to zero.
#define FloatNotZero(A) (ABS(A) > FLT_EPSILON)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment