Fixed bx::sign function to return tri-state result.

This commit is contained in:
Бранимир Караџић
2022-08-20 11:35:27 -07:00
parent a8b2d9ee4e
commit 7929f098f5
3 changed files with 13 additions and 2 deletions

View File

@@ -135,7 +135,7 @@ namespace bx
inline BX_CONSTEXPR_FUNC float sign(float _a)
{
return _a < 0.0f ? -1.0f : 1.0f;
return (0.0f < _a) - (0.0f > _a);
}
inline BX_CONSTEXPR_FUNC float abs(float _a)

View File

@@ -205,7 +205,11 @@ namespace bx
///
BX_CONSTEXPR_FUNC float invLerp(float _a, float _b, float _value);
/// Returns the sign of _a.
/// Extracts the sign of value `_a`.
///
/// @param[in] _a Value.
///
/// @returns -1 if `_a` less than zero, 0 if `_a` is equal to 0, or +1 if `_a` is greater than zero.
///
BX_CONSTEXPR_FUNC float sign(float _a);