From 4ac8eaa1c968713a63cea83079bb55ec9b05a454 Mon Sep 17 00:00:00 2001 From: Recep Aslantas Date: Wed, 26 Oct 2016 14:37:06 +0300 Subject: [PATCH] helper for get sign of integer --- include/cglm-util.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/cglm-util.h b/include/cglm-util.h index 0aa0fa8..34d6207 100644 --- a/include/cglm-util.h +++ b/include/cglm-util.h @@ -10,6 +10,17 @@ #include "cglm-common.h" +/*! + * @brief get sign of 32 bit integer as +1 or -1 + * + * @param X integer value + */ +CGLM_INLINE +int +glm_sign(int val) { + return ((val >> 31) - (-val >> 31)); +} + CGLM_INLINE float glm_rad(float deg) {