get sign of float helper as -1, +1 and 0

* add clarification for zero input
This commit is contained in:
Recep Aslantas
2018-04-02 16:18:50 +03:00
parent 54c44ff224
commit acda316c12
2 changed files with 32 additions and 2 deletions

View File

@@ -21,7 +21,9 @@
#include "common.h"
/*!
* @brief get sign of 32 bit integer as +1 or -1
* @brief get sign of 32 bit integer as +1, -1, 0
*
* Important: It returns 0 for zero input
*
* @param val integer value
*/
@@ -31,6 +33,19 @@ glm_sign(int val) {
return ((val >> 31) - (-val >> 31));
}
/*!
* @brief get sign of 32 bit float as +1, -1, 0
*
* Important: It returns 0 for zero/NaN input
*
* @param val float value
*/
CGLM_INLINE
float
glm_signf(float val) {
return (val > 0.0f) - (val < 0.0f);
}
/*!
* @brief convert degree to radians
*