This commit is contained in:
Бранимир Караџић
2024-01-01 20:03:21 -08:00
parent 03fd6f4771
commit 6c2989d95d
3 changed files with 16 additions and 16 deletions

View File

@@ -138,15 +138,15 @@ namespace bx
return float( (0.0f < _a) - (0.0f > _a) );
}
inline BX_CONSTEXPR_FUNC bool signbit(float _a)
inline BX_CONSTEXPR_FUNC bool signBit(float _a)
{
return -0.0f == _a ? 0.0f != _a : 0.0f > _a;
}
inline BX_CONSTEXPR_FUNC float copysign(float _value, float _sign)
inline BX_CONSTEXPR_FUNC float copySign(float _value, float _sign)
{
#if BX_COMPILER_MSVC
return signbit(_value) != signbit(_sign) ? -_value : _value;
return signBit(_value) != signBit(_sign) ? -_value : _value;
#else
return __builtin_copysign(_value, _sign);
#endif // BX_COMPILER_MSVC

View File

@@ -184,7 +184,7 @@ namespace bx
///
/// @returns `true` if `_a` is less than zero, otherwise returns `false`.
///
BX_CONSTEXPR_FUNC bool signbit(float _a);
BX_CONSTEXPR_FUNC bool signBit(float _a);
/// Returns value with the magnitude `_value`, and the sign of `_sign`.
///
@@ -193,7 +193,7 @@ namespace bx
///
/// @returns Value with the magnitude `_value`, and the sign of `_sign`.
///
BX_CONSTEXPR_FUNC float copysign(float _value, float _sign);
BX_CONSTEXPR_FUNC float copySign(float _value, float _sign);
/// Returns the absolute of _a.
///

View File

@@ -556,23 +556,23 @@ TEST_CASE("sign", "[math][libm]")
REQUIRE( 1 == bx::sign( bx::kFloatInfinity) );
}
TEST_CASE("signbit", "[math][libm]")
TEST_CASE("signBit", "[math][libm]")
{
STATIC_REQUIRE( bx::signbit(-0.1389f) );
STATIC_REQUIRE(!bx::signbit( 0.0000f) );
STATIC_REQUIRE(!bx::signbit( 0.1389f) );
STATIC_REQUIRE( bx::signBit(-0.1389f) );
STATIC_REQUIRE(!bx::signBit( 0.0000f) );
STATIC_REQUIRE(!bx::signBit( 0.1389f) );
REQUIRE( bx::signbit(-bx::kFloatInfinity) );
REQUIRE(!bx::signbit( bx::kFloatInfinity) );
REQUIRE( bx::signBit(-bx::kFloatInfinity) );
REQUIRE(!bx::signBit( bx::kFloatInfinity) );
}
TEST_CASE("copysign", "[math][libm]")
TEST_CASE("copySign", "[math][libm]")
{
STATIC_REQUIRE( 0.1389f == bx::copysign(-0.1389f, +1389) );
STATIC_REQUIRE(-0.0000f == bx::copysign( 0.0000f, -1389) );
STATIC_REQUIRE(-0.1389f == bx::copysign( 0.1389f, -1389) );
STATIC_REQUIRE( 0.1389f == bx::copySign(-0.1389f, +1389) );
STATIC_REQUIRE(-0.0000f == bx::copySign( 0.0000f, -1389) );
STATIC_REQUIRE(-0.1389f == bx::copySign( 0.1389f, -1389) );
REQUIRE(-bx::kFloatInfinity == bx::copysign(bx::kFloatInfinity, -1389) );
REQUIRE(-bx::kFloatInfinity == bx::copySign(bx::kFloatInfinity, -1389) );
}
TEST_CASE("bitsToFloat, floatToBits, bitsToDouble, doubleToBits", "[math]")