diff --git a/include/cglm/util.h b/include/cglm/util.h index 53b1ed5..dbba8ef 100644 --- a/include/cglm/util.h +++ b/include/cglm/util.h @@ -147,6 +147,38 @@ glm_max(float a, float b) { return b; } +/*! + * @brief find minimum of given two values + * + * @param[in] a number 1 + * @param[in] b number 2 + * + * @return smallest of the two values + */ +CGLM_INLINE +int +glm_imin(int a, int b) { + if (a < b) + return a; + return b; +} + +/*! + * @brief find maximum of given two values + * + * @param[in] a number 1 + * @param[in] b number 2 + * + * @return largest of the two values + */ +CGLM_INLINE +int +glm_imax(int a, int b) { + if (a > b) + return a; + return b; +} + /*! * @brief clamp a number between min and max *