Browse Source

MSVC: Fixed bx::signbit.

Branimir Karadžić 2 years ago
parent
commit
ae68e018a0
1 changed files with 3 additions and 7 deletions
  1. 3 7
      include/bx/inline/math.inl

+ 3 - 7
include/bx/inline/math.inl

@@ -11,6 +11,7 @@
 
 
 #include <bx/simd_t.h>
 #include <bx/simd_t.h>
 #include <bx/uint32_t.h>
 #include <bx/uint32_t.h>
+#include <float.h>
 
 
 namespace bx
 namespace bx
 {
 {
@@ -140,18 +141,13 @@ namespace bx
 
 
 	inline BX_CONSTEXPR_FUNC bool signbit(float _a)
 	inline BX_CONSTEXPR_FUNC bool signbit(float _a)
 	{
 	{
-#if BX_COMPILER_MSVC
-		return _signbit(_a);
-#else
-		return copysign(1, _a) < 0;
-//		return __builtin_signbit(_a);
-#endif // BX_COMPILER_MSVC
+		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
 #if BX_COMPILER_MSVC
-		return _copysign(_value, _sign);
+		return signbit(_value) != signbit(_sign) ? -_value : _value;
 #else
 #else
 		return __builtin_copysign(_value, _sign);
 		return __builtin_copysign(_value, _sign);
 #endif // BX_COMPILER_MSVC
 #endif // BX_COMPILER_MSVC