浏览代码

MSVC: Fixed bx::signbit.

Branimir Karadžić 2 年之前
父节点
当前提交
ae68e018a0
共有 1 个文件被更改,包括 3 次插入7 次删除
  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/uint32_t.h>
+#include <float.h>
 
 namespace bx
 {
@@ -140,18 +141,13 @@ namespace bx
 
 	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)
 	{
 #if BX_COMPILER_MSVC
-		return _copysign(_value, _sign);
+		return signbit(_value) != signbit(_sign) ? -_value : _value;
 #else
 		return __builtin_copysign(_value, _sign);
 #endif // BX_COMPILER_MSVC