From 7701a1a78918340f1730d178a1d019b55bc6e150 Mon Sep 17 00:00:00 2001 From: BeeverFeever Date: Mon, 25 Dec 2023 12:50:29 +1100 Subject: [PATCH] Add int min and max functions --- include/cglm/util.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) 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 *