mirror of
https://github.com/bkaradzic/bx.git
synced 2026-02-17 20:52:37 +01:00
Added bx::signbit, and bx::copysign.
This commit is contained in:
@@ -138,6 +138,24 @@ namespace bx
|
||||
return float( (0.0f < _a) - (0.0f > _a) );
|
||||
}
|
||||
|
||||
inline BX_CONSTEXPR_FUNC bool signbit(float _a)
|
||||
{
|
||||
#if BX_COMPILER_MSVC
|
||||
return _signbit(_a);
|
||||
#else
|
||||
return __builtin_signbit(_a);
|
||||
#endif // BX_COMPILER_MSVC
|
||||
}
|
||||
|
||||
inline BX_CONSTEXPR_FUNC float copysign(float _value, float _sign)
|
||||
{
|
||||
#if BX_COMPILER_MSVC
|
||||
return _copysign(_value, _sign);
|
||||
#else
|
||||
return __builtin_copysign(_value, _sign);
|
||||
#endif // BX_COMPILER_MSVC
|
||||
}
|
||||
|
||||
inline BX_CONSTEXPR_FUNC float abs(float _a)
|
||||
{
|
||||
return _a < 0.0f ? -_a : _a;
|
||||
|
||||
@@ -174,10 +174,27 @@ namespace bx
|
||||
///
|
||||
/// @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.
|
||||
/// @returns -1 if `_a` is 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);
|
||||
|
||||
/// Returns `true` if the velue `_a` is negative.
|
||||
///
|
||||
/// @param[in] _a Value.
|
||||
///
|
||||
/// @returns `true` if `_a` is less than zero, otherwise returns `false`.
|
||||
///
|
||||
BX_CONSTEXPR_FUNC bool signbit(float _a);
|
||||
|
||||
/// Returns value with the magnitude `_value`, and the sign of `_sign`.
|
||||
///
|
||||
/// @param[in] _value Value.
|
||||
/// @param[in] _sign Sign.
|
||||
///
|
||||
/// @returns Value with the magnitude `_value`, and the sign of `_sign`.
|
||||
///
|
||||
BX_CONSTEXPR_FUNC float copysign(float _value, float _sign);
|
||||
|
||||
/// Returns the absolute of _a.
|
||||
///
|
||||
BX_CONSTEXPR_FUNC float abs(float _a);
|
||||
|
||||
Reference in New Issue
Block a user