6#include "GenericPlatform/GenericPlatformMath.h"
7#include "Math/UnrealPlatformMathSSE4.h"
10
11
15 static FORCEINLINE bool IsNaN(
float A ) {
return _isnan(A) != 0; }
16 static FORCEINLINE bool IsNaN(
double A) {
return _isnan(A) != 0; }
17 static FORCEINLINE bool IsFinite(
float A ) {
return _finite(A) != 0; }
18 static FORCEINLINE bool IsFinite(
double A) {
return _finite(A) != 0; }
20 #pragma intrinsic(_BitScanReverse)
26 unsigned long BitIndex;
27 return _BitScanReverse(&BitIndex, Value) ? BitIndex : 0;
29 static FORCEINLINE uint8 CountLeadingZeros8(uint8 Value)
31 unsigned long BitIndex;
32 _BitScanReverse(&BitIndex, uint32(Value)*2 + 1);
33 return uint8(8 - BitIndex);
36 static FORCEINLINE uint32 CountTrailingZeros(uint32 Value)
39 unsigned long BitIndex;
40 return _BitScanForward( &BitIndex, Value ) ? BitIndex : 32;
47 return 32 - CountLeadingZeros(Arg - 1);
50 static FORCEINLINE uint32 RoundUpToPowerOfTwo(uint32 Arg)
52 return 1 << CeilLogTwo(Arg);
55 static FORCEINLINE uint64 RoundUpToPowerOfTwo64(uint64 Arg)
57 return uint64(1) << CeilLogTwo64(Arg);
62 #pragma intrinsic(_BitScanReverse64)
64 static FORCEINLINE uint64 FloorLog2_64(uint64 Value)
66 unsigned long BitIndex;
67 return _BitScanReverse64(&BitIndex, Value) ? BitIndex : 0;
74 return 64 - CountLeadingZeros64(Arg - 1);
77 static FORCEINLINE uint64 CountLeadingZeros64(uint64 Value)
81 unsigned long BitIndex;
82 if ( ! _BitScanReverse64(&BitIndex, Value) ) BitIndex = -1;
86 static FORCEINLINE uint64 CountTrailingZeros64(uint64 Value)
89 unsigned long BitIndex;
90 return _BitScanForward64( &BitIndex, Value ) ? BitIndex : 64;
93 static FORCEINLINE uint32 CountLeadingZeros(uint32 Value)
96 unsigned long BitIndex;
97 _BitScanReverse64(&BitIndex, uint64(Value)*2 + 1);