UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FGenericPlatformMath Struct Reference

#include <GenericPlatformMath.h>

+ Inheritance diagram for FGenericPlatformMath:

Public Member Functions

 RESOLVE_FLOAT_AMBIGUITY_2_ARGS (LogX)
 
 RESOLVE_FLOAT_AMBIGUITY_2_ARGS (Fmod)
 
 RESOLVE_FLOAT_AMBIGUITY_2_ARGS (Atan2)
 
 RESOLVE_FLOAT_AMBIGUITY_2_ARGS (Pow)
 
 RESOLVE_FLOAT_AMBIGUITY_2_ARGS (CopySign)
 
 MIX_FLOATS_2_ARGS (Max)
 
 MIX_FLOATS_2_ARGS (Min)
 
 MIX_SIGNED_INTS_2_ARGS_CONSTEXPR (Max)
 
 MIX_SIGNED_INTS_2_ARGS_CONSTEXPR (Min)
 
template<>
UE_FORCEINLINE_HINT float Abs (const float A)
 
template<>
UE_FORCEINLINE_HINT double Abs (const double A)
 
template<>
FORCEINLINE VectorRegister4Float Min (VectorRegister4Float A, VectorRegister4Float B)
 
template<>
FORCEINLINE VectorRegister4Double Min (VectorRegister4Double A, VectorRegister4Double B)
 
template<>
FORCEINLINE VectorRegister4Float Max (VectorRegister4Float A, VectorRegister4Float B)
 
template<>
FORCEINLINE VectorRegister4Double Max (VectorRegister4Double A, VectorRegister4Double B)
 

Static Public Member Functions

static constexpr float LoadHalf (const uint16 *Ptr)
 
static constexpr void StoreHalf (uint16 *Ptr, float Value)
 
static constexpr void VectorLoadHalf (float *RESTRICT Dst, const uint16 *RESTRICT Src)
 
static constexpr void VectorStoreHalf (uint16 *RESTRICT Dst, const float *RESTRICT Src)
 
static constexpr void WideVectorLoadHalf (float *RESTRICT Dst, const uint16 *RESTRICT Src)
 
static constexpr void WideVectorStoreHalf (uint16 *RESTRICT Dst, const float *RESTRICT Src)
 
static uint32 AsUInt (float F)
 
static uint64 AsUInt (double D)
 
static float AsFloat (uint32 U)
 
static double AsFloat (uint64 U)
 
static constexpr UE_FORCEINLINE_HINT int32 TruncToInt32 (float F)
 
static constexpr UE_FORCEINLINE_HINT int32 TruncToInt32 (double F)
 
static constexpr UE_FORCEINLINE_HINT int64 TruncToInt64 (double F)
 
static constexpr UE_FORCEINLINE_HINT int32 TruncToInt (float F)
 
static constexpr UE_FORCEINLINE_HINT int64 TruncToInt (double F)
 
static UE_FORCEINLINE_HINT float TruncToFloat (float F)
 
static UE_FORCEINLINE_HINT double TruncToDouble (double F)
 
static UE_FORCEINLINE_HINT double TruncToFloat (double F)
 
static int32 FloorToInt32 (float F)
 
static int32 FloorToInt32 (double F)
 
static int64 FloorToInt64 (double F)
 
static UE_FORCEINLINE_HINT int32 FloorToInt (float F)
 
static UE_FORCEINLINE_HINT int64 FloorToInt (double F)
 
static UE_FORCEINLINE_HINT float FloorToFloat (float F)
 
static UE_FORCEINLINE_HINT double FloorToDouble (double F)
 
static UE_FORCEINLINE_HINT double FloorToFloat (double F)
 
static UE_FORCEINLINE_HINT int32 RoundToInt32 (float F)
 
static UE_FORCEINLINE_HINT int32 RoundToInt32 (double F)
 
static UE_FORCEINLINE_HINT int64 RoundToInt64 (double F)
 
static UE_FORCEINLINE_HINT int32 RoundToInt (float F)
 
static UE_FORCEINLINE_HINT int64 RoundToInt (double F)
 
static UE_FORCEINLINE_HINT float RoundToFloat (float F)
 
static UE_FORCEINLINE_HINT double RoundToDouble (double F)
 
static UE_FORCEINLINE_HINT double RoundToFloat (double F)
 
static int32 CeilToInt32 (float F)
 
static int32 CeilToInt32 (double F)
 
static int64 CeilToInt64 (double F)
 
static UE_FORCEINLINE_HINT int32 CeilToInt (float F)
 
static UE_FORCEINLINE_HINT int64 CeilToInt (double F)
 
static UE_FORCEINLINE_HINT float CeilToFloat (float F)
 
static UE_FORCEINLINE_HINT double CeilToDouble (double F)
 
static UE_FORCEINLINE_HINT double CeilToFloat (double F)
 
static int64 RoundToNearestTiesToEven (double F)
 
static UE_FORCEINLINE_HINT float Fractional (float Value)
 
static UE_FORCEINLINE_HINT double Fractional (double Value)
 
static UE_FORCEINLINE_HINT float Frac (float Value)
 
static UE_FORCEINLINE_HINT double Frac (double Value)
 
static UE_FORCEINLINE_HINT float Modf (const float InValue, float *OutIntPart)
 
static UE_FORCEINLINE_HINT double Modf (const double InValue, double *OutIntPart)
 
static UE_FORCEINLINE_HINT float Exp (float Value)
 
static UE_FORCEINLINE_HINT double Exp (double Value)
 
static UE_FORCEINLINE_HINT float Exp2 (float Value)
 
static UE_FORCEINLINE_HINT double Exp2 (double Value)
 
static UE_FORCEINLINE_HINT float Loge (float Value)
 
static UE_FORCEINLINE_HINT double Loge (double Value)
 
static UE_FORCEINLINE_HINT float LogX (float Base, float Value)
 
static UE_FORCEINLINE_HINT double LogX (double Base, double Value)
 
static UE_FORCEINLINE_HINT float Log2 (float Value)
 
static UE_FORCEINLINE_HINT double Log2 (double Value)
 
static CORE_API FORCENOINLINE float Fmod (float X, float Y)
 
static CORE_API FORCENOINLINE double Fmod (double X, double Y)
 
static UE_FORCEINLINE_HINT float Sin (float Value)
 
static UE_FORCEINLINE_HINT double Sin (double Value)
 
static UE_FORCEINLINE_HINT float Asin (float Value)
 
static UE_FORCEINLINE_HINT double Asin (double Value)
 
static UE_FORCEINLINE_HINT float Sinh (float Value)
 
static UE_FORCEINLINE_HINT double Sinh (double Value)
 
static UE_FORCEINLINE_HINT float Cos (float Value)
 
static UE_FORCEINLINE_HINT double Cos (double Value)
 
static UE_FORCEINLINE_HINT float Acos (float Value)
 
static UE_FORCEINLINE_HINT double Acos (double Value)
 
static UE_FORCEINLINE_HINT float Cosh (float Value)
 
static UE_FORCEINLINE_HINT double Cosh (double Value)
 
static UE_FORCEINLINE_HINT float Tan (float Value)
 
static UE_FORCEINLINE_HINT double Tan (double Value)
 
static UE_FORCEINLINE_HINT float Atan (float Value)
 
static UE_FORCEINLINE_HINT double Atan (double Value)
 
static UE_FORCEINLINE_HINT float Tanh (float Value)
 
static UE_FORCEINLINE_HINT double Tanh (double Value)
 
static CORE_API float Atan2 (float Y, float X)
 
static CORE_API double Atan2 (double Y, double X)
 
static UE_FORCEINLINE_HINT float Sqrt (float Value)
 
static UE_FORCEINLINE_HINT double Sqrt (double Value)
 
static UE_FORCEINLINE_HINT float Pow (float A, float B)
 
static UE_FORCEINLINE_HINT double Pow (double A, double B)
 
static UE_FORCEINLINE_HINT float InvSqrt (float F)
 
static UE_FORCEINLINE_HINT double InvSqrt (double F)
 
static UE_FORCEINLINE_HINT float InvSqrtEst (float F)
 
static UE_FORCEINLINE_HINT double InvSqrtEst (double F)
 
static UE_FORCEINLINE_HINT float CopySign (float X, float Y)
 
static UE_FORCEINLINE_HINT double CopySign (double X, double Y)
 
static UE_FORCEINLINE_HINT bool IsNaN (float A)
 
static UE_FORCEINLINE_HINT bool IsNaN (double A)
 
static UE_FORCEINLINE_HINT bool IsFinite (float A)
 
static UE_FORCEINLINE_HINT bool IsFinite (double A)
 
static UE_FORCEINLINE_HINT bool IsNegativeOrNegativeZero (float A)
 
static UE_FORCEINLINE_HINT bool IsNegativeOrNegativeZero (double A)
 
static UE_FORCEINLINE_HINT bool IsNegativeFloat (float A)
 
static UE_FORCEINLINE_HINT bool IsNegativeDouble (double A)
 
static UE_FORCEINLINE_HINT bool IsNegative (float A)
 
static UE_FORCEINLINE_HINT bool IsNegative (double A)
 
static UE_FORCEINLINE_HINT int32 Rand ()
 
static UE_FORCEINLINE_HINT int32 Rand32 ()
 
static UE_FORCEINLINE_HINT void RandInit (int32 Seed)
 
static float FRand ()
 
static CORE_API void SRandInit (int32 Seed)
 
static CORE_API int32 GetRandSeed ()
 
static CORE_API float SRand ()
 
static constexpr uint32 FloorLog2 (uint32 Value)
 
static constexpr UE_FORCEINLINE_HINT uint32 FloorLog2NonZero (uint32 Value)
 
static constexpr uint64 FloorLog2_64 (uint64 Value)
 
static constexpr UE_FORCEINLINE_HINT uint64 FloorLog2NonZero_64 (uint64 Value)
 
static constexpr uint8 CountLeadingZeros8 (uint8 Value)
 
static constexpr uint32 CountLeadingZeros (uint32 Value)
 
static constexpr uint64 CountLeadingZeros64 (uint64 Value)
 
static constexpr uint32 CountTrailingZeros (uint32 Value)
 
static constexpr UE_FORCEINLINE_HINT uint32 CountTrailingZerosConstExpr (uint32 Value)
 
static constexpr uint64 CountTrailingZeros64 (uint64 Value)
 
static constexpr UE_FORCEINLINE_HINT uint64 CountTrailingZeros64ConstExpr (uint64 Value)
 
static constexpr uint32 CeilLogTwo (uint32 Arg)
 
static constexpr uint64 CeilLogTwo64 (uint64 Arg)
 
static constexpr uint8 ConstExprCeilLogTwo (SIZE_T Arg)
 
static constexpr UE_FORCEINLINE_HINT uint32 RoundUpToPowerOfTwo (uint32 Arg)
 
static constexpr UE_FORCEINLINE_HINT uint64 RoundUpToPowerOfTwo64 (uint64 V)
 
static constexpr uint32 MortonCode2 (uint32 x)
 
static constexpr uint64 MortonCode2_64 (uint64 x)
 
static constexpr uint32 ReverseMortonCode2 (uint32 x)
 
static constexpr uint64 ReverseMortonCode2_64 (uint64 x)
 
static constexpr uint32 MortonCode3 (uint32 x)
 
static constexpr uint32 ReverseMortonCode3 (uint32 x)
 
static constexpr UE_FORCEINLINE_HINT float FloatSelect (float Comparand, float ValueGEZero, float ValueLTZero)
 
static constexpr UE_FORCEINLINE_HINT double FloatSelect (double Comparand, double ValueGEZero, double ValueLTZero)
 
template<class T >
static constexpr UE_FORCEINLINE_HINTAbs (const T A)
 
template<class T >
static constexpr UE_FORCEINLINE_HINTSign (const T A)
 
template<typename T >
static constexpr UE_FORCEINLINE_HINTMax (T A, T B)
 
template<typename T , typename... OtherTypes>
static constexprMax (T A, OtherTypes... Others)
 
template<typename T >
static constexpr UE_FORCEINLINE_HINTMin (T A, T B)
 
template<typename T , typename... OtherTypes>
static constexprMin (T A, OtherTypes... Others)
 
template<class T >
staticMin (const TArray< T > &Values)
 
template<class T >
staticMin (const TArray< T > &Values, int32 *MinIndex)
 
template<class T >
staticMax (const TArray< T > &Values)
 
template<class T >
staticMax (const TArray< T > &Values, int32 *MaxIndex)
 
template<class T >
static constexpr void GetMinMax (const T &A, const T &B, T &OutMin, T &OutMax)
 
template<class T >
static constexpr void GetMinMax (T &Min, T &Max)
 
static constexpr int32 CountBits (uint64 Bits)
 
template<UE::CIntegral IntType>
static bool AddAndCheckForOverflow (IntType A, IntType B, IntType &OutResult)
 
template<UE::CIntegral IntType>
static bool SubtractAndCheckForOverflow (IntType A, IntType B, IntType &OutResult)
 
template<UE::CIntegral IntType>
static bool MultiplyAndCheckForOverflow (IntType A, IntType B, IntType &OutResult)
 

Detailed Description

Generic implementation for most platforms

Member Function Documentation

◆ Abs() [1/3]

template<>
UE_FORCEINLINE_HINT double FGenericPlatformMath::Abs ( const double  A)

◆ Abs() [2/3]

template<>
UE_FORCEINLINE_HINT float FGenericPlatformMath::Abs ( const float  A)

Float specialization

◆ Abs() [3/3]

template<class T >
static constexpr UE_FORCEINLINE_HINT T FGenericPlatformMath::Abs ( const T  A)
inlinestaticconstexpr

Computes absolute value in a generic way

◆ Acos() [1/2]

static UE_FORCEINLINE_HINT double FGenericPlatformMath::Acos ( double  Value)
inlinestatic

◆ Acos() [2/2]

static UE_FORCEINLINE_HINT float FGenericPlatformMath::Acos ( float  Value)
inlinestatic

◆ AddAndCheckForOverflow()

template<UE::CIntegral IntType>
static bool FGenericPlatformMath::AddAndCheckForOverflow ( IntType  A,
IntType  B,
IntType &  OutResult 
)
inlinestatic

Adds two integers of any integer type, checking for overflow. If there was overflow, it returns false, and OutResult may or may not be written. If there wasn't overflow, it returns true, and the result of the addition is written to OutResult.

◆ AsFloat() [1/2]

static float FGenericPlatformMath::AsFloat ( uint32  U)
inlinestatic

Performs a bit cast of the given unsigned int to float of the same bit width.

Parameters
UThe 32-bit unsigned int to bit cast to a 32-bit float.
Returns
A bitwise copy of the 32-bit float in a 32-bit unsigned integer value.

◆ AsFloat() [2/2]

static double FGenericPlatformMath::AsFloat ( uint64  U)
inlinestatic

Performs a bit cast of the given unsigned int to float of the same bit width.

Parameters
UThe 64-bit unsigned int to bit cast to a 64-bit float.
Returns
A bitwise copy of the 64-bit float in a 64-bit unsigned integer value.

◆ Asin() [1/2]

static UE_FORCEINLINE_HINT double FGenericPlatformMath::Asin ( double  Value)
inlinestatic

◆ Asin() [2/2]

static UE_FORCEINLINE_HINT float FGenericPlatformMath::Asin ( float  Value)
inlinestatic

◆ AsUInt() [1/2]

static uint64 FGenericPlatformMath::AsUInt ( double  D)
inlinestatic

Performs a bit cast of the given double to an unsigned int of the same bit width.

Parameters
DThe double to bit cast to an unsigned integer.
Returns
A bitwise copy of the double in a 64-bit unsigned integer value.

◆ AsUInt() [2/2]

static uint32 FGenericPlatformMath::AsUInt ( float  F)
inlinestatic

Performs a bit cast of the given float to an unsigned int of the same bit width.

Parameters
FThe float to bit cast to an unsigned integer.
Returns
A bitwise copy of the float in a 32-bit unsigned integer value.

◆ Atan() [1/2]

static UE_FORCEINLINE_HINT double FGenericPlatformMath::Atan ( double  Value)
inlinestatic

◆ Atan() [2/2]

static UE_FORCEINLINE_HINT float FGenericPlatformMath::Atan ( float  Value)
inlinestatic

◆ Atan2() [1/2]

double FGenericPlatformMath::Atan2 ( double  Y,
double  X 
)
static

◆ Atan2() [2/2]

float FGenericPlatformMath::Atan2 ( float  Y,
float  X 
)
static

◆ CeilLogTwo()

static constexpr uint32 FGenericPlatformMath::CeilLogTwo ( uint32  Arg)
inlinestaticconstexpr

Returns smallest N such that (1<<N)>=Arg. Note: CeilLogTwo(0)=0

◆ CeilLogTwo64()

static constexpr uint64 FGenericPlatformMath::CeilLogTwo64 ( uint64  Arg)
inlinestaticconstexpr

◆ CeilToDouble()

static UE_FORCEINLINE_HINT double FGenericPlatformMath::CeilToDouble ( double  F)
inlinestatic

Converts a double to the nearest greater or equal integer.

Parameters
FFloating point value to convert
Returns
An integer greater or equal to 'F'.

◆ CeilToFloat() [1/2]

static UE_FORCEINLINE_HINT double FGenericPlatformMath::CeilToFloat ( double  F)
inlinestatic

◆ CeilToFloat() [2/2]

static UE_FORCEINLINE_HINT float FGenericPlatformMath::CeilToFloat ( float  F)
inlinestatic

Converts a float to the nearest greater or equal integer.

Parameters
FFloating point value to convert
Returns
An integer greater or equal to 'F'.

◆ CeilToInt() [1/2]

static UE_FORCEINLINE_HINT int64 FGenericPlatformMath::CeilToInt ( double  F)
inlinestatic

◆ CeilToInt() [2/2]

static UE_FORCEINLINE_HINT int32 FGenericPlatformMath::CeilToInt ( float  F)
inlinestatic

◆ CeilToInt32() [1/2]

static int32 FGenericPlatformMath::CeilToInt32 ( double  F)
inlinestatic

◆ CeilToInt32() [2/2]

static int32 FGenericPlatformMath::CeilToInt32 ( float  F)
inlinestatic

Converts a float to the nearest greater or equal integer.

Parameters
FFloating point value to convert
Returns
An integer greater or equal to 'F'.

◆ CeilToInt64()

static int64 FGenericPlatformMath::CeilToInt64 ( double  F)
inlinestatic

◆ ConstExprCeilLogTwo()

static constexpr uint8 FGenericPlatformMath::ConstExprCeilLogTwo ( SIZE_T  Arg)
inlinestaticconstexpr

Returns the smallest N such that (1<<N)>=Arg. This is a less efficient version of CeilLogTwo, but written in a way that can be evaluated at compile-time.

◆ CopySign() [1/2]

static UE_FORCEINLINE_HINT double FGenericPlatformMath::CopySign ( double  X,
double  Y 
)
inlinestatic

◆ CopySign() [2/2]

static UE_FORCEINLINE_HINT float FGenericPlatformMath::CopySign ( float  X,
float  Y 
)
inlinestatic

Composes a floating-point value with the magnitude of X and the sign of Y.

◆ Cos() [1/2]

static UE_FORCEINLINE_HINT double FGenericPlatformMath::Cos ( double  Value)
inlinestatic

◆ Cos() [2/2]

static UE_FORCEINLINE_HINT float FGenericPlatformMath::Cos ( float  Value)
inlinestatic

◆ Cosh() [1/2]

static UE_FORCEINLINE_HINT double FGenericPlatformMath::Cosh ( double  Value)
inlinestatic

◆ Cosh() [2/2]

static UE_FORCEINLINE_HINT float FGenericPlatformMath::Cosh ( float  Value)
inlinestatic

◆ CountBits()

static constexpr int32 FGenericPlatformMath::CountBits ( uint64  Bits)
inlinestaticconstexpr

◆ CountLeadingZeros()

static constexpr uint32 FGenericPlatformMath::CountLeadingZeros ( uint32  Value)
inlinestaticconstexpr

Counts the number of leading zeros in the bit representation of the 32-bit value

Parameters
Valuethe value to determine the number of leading zeros for
Returns
the number of zeros before the first "on" bit

◆ CountLeadingZeros64()

static constexpr uint64 FGenericPlatformMath::CountLeadingZeros64 ( uint64  Value)
inlinestaticconstexpr

Counts the number of leading zeros in the bit representation of the 64-bit value

Parameters
Valuethe value to determine the number of leading zeros for
Returns
the number of zeros before the first "on" bit

◆ CountLeadingZeros8()

static constexpr uint8 FGenericPlatformMath::CountLeadingZeros8 ( uint8  Value)
inlinestaticconstexpr

Counts the number of leading zeros in the bit representation of the 8-bit value

Parameters
Valuethe value to determine the number of leading zeros for
Returns
the number of zeros before the first "on" bit

◆ CountTrailingZeros()

static constexpr uint32 FGenericPlatformMath::CountTrailingZeros ( uint32  Value)
inlinestaticconstexpr

Counts the number of trailing zeros in the bit representation of the value

Parameters
Valuethe value to determine the number of trailing zeros for
Returns
the number of zeros after the last "on" bit

◆ CountTrailingZeros64()

static constexpr uint64 FGenericPlatformMath::CountTrailingZeros64 ( uint64  Value)
inlinestaticconstexpr

Counts the number of trailing zeros in the bit representation of the value

Parameters
Valuethe value to determine the number of trailing zeros for
Returns
the number of zeros after the last "on" bit

◆ CountTrailingZeros64ConstExpr()

static constexpr UE_FORCEINLINE_HINT uint64 FGenericPlatformMath::CountTrailingZeros64ConstExpr ( uint64  Value)
inlinestaticconstexpr

◆ CountTrailingZerosConstExpr()

static constexpr UE_FORCEINLINE_HINT uint32 FGenericPlatformMath::CountTrailingZerosConstExpr ( uint32  Value)
inlinestaticconstexpr

◆ Exp() [1/2]

static UE_FORCEINLINE_HINT double FGenericPlatformMath::Exp ( double  Value)
inlinestatic

◆ Exp() [2/2]

static UE_FORCEINLINE_HINT float FGenericPlatformMath::Exp ( float  Value)
inlinestatic

◆ Exp2() [1/2]

static UE_FORCEINLINE_HINT double FGenericPlatformMath::Exp2 ( double  Value)
inlinestatic

◆ Exp2() [2/2]

static UE_FORCEINLINE_HINT float FGenericPlatformMath::Exp2 ( float  Value)
inlinestatic

◆ FloatSelect() [1/2]

static constexpr UE_FORCEINLINE_HINT double FGenericPlatformMath::FloatSelect ( double  Comparand,
double  ValueGEZero,
double  ValueLTZero 
)
inlinestaticconstexpr

Returns value based on comparand. The main purpose of this function is to avoid branching based on floating point comparison which can be avoided via compiler intrinsics.

Please note that we don't define what happens in the case of NaNs as there might be platform specific differences.

Parameters
ComparandComparand the results are based on
ValueGEZeroReturn value if Comparand >= 0
ValueLTZeroReturn value if Comparand < 0
Returns
ValueGEZero if Comparand >= 0, ValueLTZero otherwise

◆ FloatSelect() [2/2]

static constexpr UE_FORCEINLINE_HINT float FGenericPlatformMath::FloatSelect ( float  Comparand,
float  ValueGEZero,
float  ValueLTZero 
)
inlinestaticconstexpr

Returns value based on comparand. The main purpose of this function is to avoid branching based on floating point comparison which can be avoided via compiler intrinsics.

Please note that we don't define what happens in the case of NaNs as there might be platform specific differences.

Parameters
ComparandComparand the results are based on
ValueGEZeroReturn value if Comparand >= 0
ValueLTZeroReturn value if Comparand < 0
Returns
ValueGEZero if Comparand >= 0, ValueLTZero otherwise

◆ FloorLog2()

static constexpr uint32 FGenericPlatformMath::FloorLog2 ( uint32  Value)
inlinestaticconstexpr

Computes the base 2 logarithm for an integer value. The result is rounded down to the nearest integer.

Parameters
ValueThe value to compute the log of
Returns
Log2 of Value. 0 if Value is 0.

◆ FloorLog2_64()

static constexpr uint64 FGenericPlatformMath::FloorLog2_64 ( uint64  Value)
inlinestaticconstexpr

Computes the base 2 logarithm for a 64-bit value. The result is rounded down to the nearest integer.

Parameters
ValueThe value to compute the log of
Returns
Log2 of Value. 0 if Value is 0.

◆ FloorLog2NonZero()

static constexpr UE_FORCEINLINE_HINT uint32 FGenericPlatformMath::FloorLog2NonZero ( uint32  Value)
inlinestaticconstexpr

FloorLog2 but the caller guarantees that Value is not 0.

◆ FloorLog2NonZero_64()

static constexpr UE_FORCEINLINE_HINT uint64 FGenericPlatformMath::FloorLog2NonZero_64 ( uint64  Value)
inlinestaticconstexpr

FloorLog2_64 but the caller guarantees that Value is not 0.

◆ FloorToDouble()

static UE_FORCEINLINE_HINT double FGenericPlatformMath::FloorToDouble ( double  F)
inlinestatic

Converts a double to a less or equal integer.

Parameters
FFloating point value to convert
Returns
The nearest integer value to 'F'.

◆ FloorToFloat() [1/2]

static UE_FORCEINLINE_HINT double FGenericPlatformMath::FloorToFloat ( double  F)
inlinestatic

◆ FloorToFloat() [2/2]

static UE_FORCEINLINE_HINT float FGenericPlatformMath::FloorToFloat ( float  F)
inlinestatic

Converts a float to the nearest less or equal integer.

Parameters
FFloating point value to convert
Returns
An integer less or equal to 'F'.

◆ FloorToInt() [1/2]

static UE_FORCEINLINE_HINT int64 FGenericPlatformMath::FloorToInt ( double  F)
inlinestatic

◆ FloorToInt() [2/2]

static UE_FORCEINLINE_HINT int32 FGenericPlatformMath::FloorToInt ( float  F)
inlinestatic

◆ FloorToInt32() [1/2]

static int32 FGenericPlatformMath::FloorToInt32 ( double  F)
inlinestatic

◆ FloorToInt32() [2/2]

static int32 FGenericPlatformMath::FloorToInt32 ( float  F)
inlinestatic

Converts a float to a nearest less or equal integer.

Parameters
FFloating point value to convert
Returns
An integer less or equal to 'F'.

◆ FloorToInt64()

static int64 FGenericPlatformMath::FloorToInt64 ( double  F)
inlinestatic

◆ Fmod() [1/2]

double FGenericPlatformMath::Fmod ( double  X,
double  Y 
)
static

◆ Fmod() [2/2]

float FGenericPlatformMath::Fmod ( float  X,
float  Y 
)
static

Returns the floating-point remainder of X / Y Warning: Always returns remainder toward 0, not toward the smaller multiple of Y. So for example Fmod(2.8f, 2) gives .8f as you would expect, however, Fmod(-2.8f, 2) gives -.8f, NOT 1.2f Use Floor instead when snapping positions that can be negative to a grid

This is forced to NOT inline so that divisions by constant Y does not get optimized in to an inverse scalar multiply, which is not consistent with the intent nor with the vectorized version.

◆ Frac() [1/2]

static UE_FORCEINLINE_HINT double FGenericPlatformMath::Frac ( double  Value)
inlinestatic

◆ Frac() [2/2]

static UE_FORCEINLINE_HINT float FGenericPlatformMath::Frac ( float  Value)
inlinestatic

Returns the fractional part of a float.

Parameters
ValueFloating point value to convert
Returns
A float between >=0 and < 1.

◆ Fractional() [1/2]

static UE_FORCEINLINE_HINT double FGenericPlatformMath::Fractional ( double  Value)
inlinestatic

◆ Fractional() [2/2]

static UE_FORCEINLINE_HINT float FGenericPlatformMath::Fractional ( float  Value)
inlinestatic

Returns signed fractional part of a float.

Parameters
ValueFloating point value to convert
Returns
A float between >=0 and < 1 for nonnegative input. A float between >= -1 and < 0 for negative input.

◆ FRand()

static float FGenericPlatformMath::FRand ( )
inlinestatic

Returns a random float between 0 and 1, inclusive.

◆ GetMinMax() [1/2]

template<class T >
static constexpr void FGenericPlatformMath::GetMinMax ( const T &  A,
const T &  B,
T &  OutMin,
T &  OutMax 
)
inlinestaticconstexpr

Sort input A & B values into OutMin & OutMax

◆ GetMinMax() [2/2]

template<class T >
static constexpr void FGenericPlatformMath::GetMinMax ( T &  Min,
T &  Max 
)
inlinestaticconstexpr

Sort input values to be Min and Max

◆ GetRandSeed()

int32 FGenericPlatformMath::GetRandSeed ( )
static

Returns the current seed for SRand().

◆ InvSqrt() [1/2]

static UE_FORCEINLINE_HINT double FGenericPlatformMath::InvSqrt ( double  F)
inlinestatic

◆ InvSqrt() [2/2]

static UE_FORCEINLINE_HINT float FGenericPlatformMath::InvSqrt ( float  F)
inlinestatic

Computes a fully accurate inverse square root

◆ InvSqrtEst() [1/2]

static UE_FORCEINLINE_HINT double FGenericPlatformMath::InvSqrtEst ( double  F)
inlinestatic

◆ InvSqrtEst() [2/2]

static UE_FORCEINLINE_HINT float FGenericPlatformMath::InvSqrtEst ( float  F)
inlinestatic

Computes a faster but less accurate inverse square root

◆ IsFinite() [1/2]

static UE_FORCEINLINE_HINT bool FGenericPlatformMath::IsFinite ( double  A)
inlinestatic

◆ IsFinite() [2/2]

static UE_FORCEINLINE_HINT bool FGenericPlatformMath::IsFinite ( float  A)
inlinestatic

Return true if value is finite (not NaN and not Infinity).

◆ IsNaN() [1/2]

static UE_FORCEINLINE_HINT bool FGenericPlatformMath::IsNaN ( double  A)
inlinestatic

◆ IsNaN() [2/2]

static UE_FORCEINLINE_HINT bool FGenericPlatformMath::IsNaN ( float  A)
inlinestatic

Return true if value is NaN (not a number).

◆ IsNegative() [1/2]

static UE_FORCEINLINE_HINT bool FGenericPlatformMath::IsNegative ( double  A)
inlinestatic

◆ IsNegative() [2/2]

static UE_FORCEINLINE_HINT bool FGenericPlatformMath::IsNegative ( float  A)
inlinestatic

◆ IsNegativeDouble()

static UE_FORCEINLINE_HINT bool FGenericPlatformMath::IsNegativeDouble ( double  A)
inlinestatic

◆ IsNegativeFloat()

static UE_FORCEINLINE_HINT bool FGenericPlatformMath::IsNegativeFloat ( float  A)
inlinestatic

◆ IsNegativeOrNegativeZero() [1/2]

static UE_FORCEINLINE_HINT bool FGenericPlatformMath::IsNegativeOrNegativeZero ( double  A)
inlinestatic

◆ IsNegativeOrNegativeZero() [2/2]

static UE_FORCEINLINE_HINT bool FGenericPlatformMath::IsNegativeOrNegativeZero ( float  A)
inlinestatic

◆ LoadHalf()

static constexpr float FGenericPlatformMath::LoadHalf ( const uint16 Ptr)
inlinestaticconstexpr

◆ Log2() [1/2]

static UE_FORCEINLINE_HINT double FGenericPlatformMath::Log2 ( double  Value)
inlinestatic

◆ Log2() [2/2]

static UE_FORCEINLINE_HINT float FGenericPlatformMath::Log2 ( float  Value)
inlinestatic

◆ Loge() [1/2]

static UE_FORCEINLINE_HINT double FGenericPlatformMath::Loge ( double  Value)
inlinestatic

◆ Loge() [2/2]

static UE_FORCEINLINE_HINT float FGenericPlatformMath::Loge ( float  Value)
inlinestatic

◆ LogX() [1/2]

static UE_FORCEINLINE_HINT double FGenericPlatformMath::LogX ( double  Base,
double  Value 
)
inlinestatic

◆ LogX() [2/2]

static UE_FORCEINLINE_HINT float FGenericPlatformMath::LogX ( float  Base,
float  Value 
)
inlinestatic

◆ Max() [1/6]

template<class T >
static T FGenericPlatformMath::Max ( const TArray< T > &  Values)
inlinestatic

Max of Array

Parameters
ValuesArray of templated type
Returns
The max value found in the array or default value if the array was empty

◆ Max() [2/6]

template<class T >
static T FGenericPlatformMath::Max ( const TArray< T > &  Values,
int32 MaxIndex 
)
inlinestatic

Max of Array

Parameters
ValuesArray of templated type
MaxIndexOptional pointer for returning the index of the maximum element, if multiple maximum elements the first index is returned
Returns
The max value found in the array or default value if the array was empty

◆ Max() [3/6]

template<typename T , typename... OtherTypes>
static constexpr T FGenericPlatformMath::Max ( A,
OtherTypes...  Others 
)
inlinestaticconstexpr

◆ Max() [4/6]

template<typename T >
static constexpr UE_FORCEINLINE_HINT T FGenericPlatformMath::Max ( A,
B 
)
inlinestaticconstexpr

Returns higher value in a generic way

◆ Max() [5/6]

template<>
FORCEINLINE VectorRegister4Double FGenericPlatformMath::Max ( VectorRegister4Double  A,
VectorRegister4Double  B 
)

◆ Max() [6/6]

template<>
FORCEINLINE VectorRegister4Float FGenericPlatformMath::Max ( VectorRegister4Float  A,
VectorRegister4Float  B 
)

Returns the larger of the two values (operates on each component individually)

◆ Min() [1/6]

template<class T >
static T FGenericPlatformMath::Min ( const TArray< T > &  Values)
inlinestatic

Min of Array

Parameters
ValuesArray of templated type
Returns
The min value found in the array or default value if the array was empty

◆ Min() [2/6]

template<class T >
static T FGenericPlatformMath::Min ( const TArray< T > &  Values,
int32 MinIndex 
)
inlinestatic

Min of Array

Parameters
ValuesArray of templated type
MinIndexOptional pointer for returning the index of the minimum element, if multiple minimum elements the first index is returned
Returns
The min value found in the array or default value if the array was empty

◆ Min() [3/6]

template<typename T , typename... OtherTypes>
static constexpr T FGenericPlatformMath::Min ( A,
OtherTypes...  Others 
)
inlinestaticconstexpr

◆ Min() [4/6]

template<typename T >
static constexpr UE_FORCEINLINE_HINT T FGenericPlatformMath::Min ( A,
B 
)
inlinestaticconstexpr

Returns lower value in a generic way

◆ Min() [5/6]

template<>
FORCEINLINE VectorRegister4Double FGenericPlatformMath::Min ( VectorRegister4Double  A,
VectorRegister4Double  B 
)

◆ Min() [6/6]

template<>
FORCEINLINE VectorRegister4Float FGenericPlatformMath::Min ( VectorRegister4Float  A,
VectorRegister4Float  B 
)

Returns the smaller of the two values (operates on each component individually)

◆ MIX_FLOATS_2_ARGS() [1/2]

FGenericPlatformMath::MIX_FLOATS_2_ARGS ( Max  )

◆ MIX_FLOATS_2_ARGS() [2/2]

FGenericPlatformMath::MIX_FLOATS_2_ARGS ( Min  )

◆ MIX_SIGNED_INTS_2_ARGS_CONSTEXPR() [1/2]

FGenericPlatformMath::MIX_SIGNED_INTS_2_ARGS_CONSTEXPR ( Max  )

◆ MIX_SIGNED_INTS_2_ARGS_CONSTEXPR() [2/2]

FGenericPlatformMath::MIX_SIGNED_INTS_2_ARGS_CONSTEXPR ( Min  )

◆ Modf() [1/2]

static UE_FORCEINLINE_HINT double FGenericPlatformMath::Modf ( const double  InValue,
double OutIntPart 
)
inlinestatic

Breaks the given value into an integral and a fractional part.

Parameters
InValueFloating point value to convert
OutIntPartFloating point value that receives the integral part of the number.
Returns
The fractional part of the number.

◆ Modf() [2/2]

static UE_FORCEINLINE_HINT float FGenericPlatformMath::Modf ( const float  InValue,
float OutIntPart 
)
inlinestatic

Breaks the given value into an integral and a fractional part.

Parameters
InValueFloating point value to convert
OutIntPartFloating point value that receives the integral part of the number.
Returns
The fractional part of the number.

◆ MortonCode2()

static constexpr uint32 FGenericPlatformMath::MortonCode2 ( uint32  x)
inlinestaticconstexpr

Spreads bits to every other.

◆ MortonCode2_64()

static constexpr uint64 FGenericPlatformMath::MortonCode2_64 ( uint64  x)
inlinestaticconstexpr

◆ MortonCode3()

static constexpr uint32 FGenericPlatformMath::MortonCode3 ( uint32  x)
inlinestaticconstexpr

Spreads bits to every 3rd.

◆ MultiplyAndCheckForOverflow()

template<UE::CIntegral IntType>
static bool FGenericPlatformMath::MultiplyAndCheckForOverflow ( IntType  A,
IntType  B,
IntType &  OutResult 
)
inlinestatic

Multiplies two integers of any integer type, checking for overflow. If there was overflow, it returns false, and OutResult may or may not be written. If there wasn't overflow, it returns true, and the result of the multiplication is written to OutResult.

◆ Pow() [1/2]

static UE_FORCEINLINE_HINT double FGenericPlatformMath::Pow ( double  A,
double  B 
)
inlinestatic

◆ Pow() [2/2]

static UE_FORCEINLINE_HINT float FGenericPlatformMath::Pow ( float  A,
float  B 
)
inlinestatic

◆ Rand()

static UE_FORCEINLINE_HINT int32 FGenericPlatformMath::Rand ( )
inlinestatic

Returns a random integer between 0 and RAND_MAX, inclusive

◆ Rand32()

static UE_FORCEINLINE_HINT int32 FGenericPlatformMath::Rand32 ( )
inlinestatic

Returns a random integer between 0 and MAX_int32, inclusive. RAND_MAX may only be 15 bits, so compose from multiple calls.

◆ RandInit()

static UE_FORCEINLINE_HINT void FGenericPlatformMath::RandInit ( int32  Seed)
inlinestatic

Seeds global random number functions Rand() and FRand()

◆ RESOLVE_FLOAT_AMBIGUITY_2_ARGS() [1/5]

FGenericPlatformMath::RESOLVE_FLOAT_AMBIGUITY_2_ARGS ( Atan2  )

◆ RESOLVE_FLOAT_AMBIGUITY_2_ARGS() [2/5]

FGenericPlatformMath::RESOLVE_FLOAT_AMBIGUITY_2_ARGS ( CopySign  )

◆ RESOLVE_FLOAT_AMBIGUITY_2_ARGS() [3/5]

FGenericPlatformMath::RESOLVE_FLOAT_AMBIGUITY_2_ARGS ( Fmod  )

◆ RESOLVE_FLOAT_AMBIGUITY_2_ARGS() [4/5]

FGenericPlatformMath::RESOLVE_FLOAT_AMBIGUITY_2_ARGS ( LogX  )

◆ RESOLVE_FLOAT_AMBIGUITY_2_ARGS() [5/5]

FGenericPlatformMath::RESOLVE_FLOAT_AMBIGUITY_2_ARGS ( Pow  )

◆ ReverseMortonCode2()

static constexpr uint32 FGenericPlatformMath::ReverseMortonCode2 ( uint32  x)
inlinestaticconstexpr

Reverses MortonCode2. Compacts every other bit to the right.

◆ ReverseMortonCode2_64()

static constexpr uint64 FGenericPlatformMath::ReverseMortonCode2_64 ( uint64  x)
inlinestaticconstexpr

◆ ReverseMortonCode3()

static constexpr uint32 FGenericPlatformMath::ReverseMortonCode3 ( uint32  x)
inlinestaticconstexpr

Reverses MortonCode3. Compacts every 3rd bit to the right.

◆ RoundToDouble()

static UE_FORCEINLINE_HINT double FGenericPlatformMath::RoundToDouble ( double  F)
inlinestatic

Converts a double to the nearest integer. Rounds up when the fraction is .5

Parameters
FFloating point value to convert
Returns
The nearest integer to 'F'.

◆ RoundToFloat() [1/2]

static UE_FORCEINLINE_HINT double FGenericPlatformMath::RoundToFloat ( double  F)
inlinestatic

◆ RoundToFloat() [2/2]

static UE_FORCEINLINE_HINT float FGenericPlatformMath::RoundToFloat ( float  F)
inlinestatic

Converts a float to the nearest integer. Rounds up when the fraction is .5

Parameters
FFloating point value to convert
Returns
The nearest integer to 'F'.

◆ RoundToInt() [1/2]

static UE_FORCEINLINE_HINT int64 FGenericPlatformMath::RoundToInt ( double  F)
inlinestatic

◆ RoundToInt() [2/2]

static UE_FORCEINLINE_HINT int32 FGenericPlatformMath::RoundToInt ( float  F)
inlinestatic

◆ RoundToInt32() [1/2]

static UE_FORCEINLINE_HINT int32 FGenericPlatformMath::RoundToInt32 ( double  F)
inlinestatic

◆ RoundToInt32() [2/2]

static UE_FORCEINLINE_HINT int32 FGenericPlatformMath::RoundToInt32 ( float  F)
inlinestatic

Converts a float to the nearest integer. Rounds up when the fraction is .5

Parameters
FFloating point value to convert
Returns
The nearest integer to 'F'.

◆ RoundToInt64()

static UE_FORCEINLINE_HINT int64 FGenericPlatformMath::RoundToInt64 ( double  F)
inlinestatic

◆ RoundToNearestTiesToEven()

static int64 FGenericPlatformMath::RoundToNearestTiesToEven ( double  F)
inlinestatic

Converts a double to nearest int64 with ties rounding to nearest even May incur a performance penalty. Asserts on platforms that do not support this mode.

Parameters
FDouble precision floating point value to convert
Returns
The 64-bit integer closest to 'F', with ties going to the nearest even number

◆ RoundUpToPowerOfTwo()

static constexpr UE_FORCEINLINE_HINT uint32 FGenericPlatformMath::RoundUpToPowerOfTwo ( uint32  Arg)
inlinestaticconstexpr
Returns
Rounds the given number up to the next highest power of two.

◆ RoundUpToPowerOfTwo64()

static constexpr UE_FORCEINLINE_HINT uint64 FGenericPlatformMath::RoundUpToPowerOfTwo64 ( uint64  V)
inlinestaticconstexpr

◆ Sign()

template<class T >
static constexpr UE_FORCEINLINE_HINT T FGenericPlatformMath::Sign ( const T  A)
inlinestaticconstexpr

Returns 1, 0, or -1 depending on relation of T to 0

◆ Sin() [1/2]

static UE_FORCEINLINE_HINT double FGenericPlatformMath::Sin ( double  Value)
inlinestatic

◆ Sin() [2/2]

static UE_FORCEINLINE_HINT float FGenericPlatformMath::Sin ( float  Value)
inlinestatic

◆ Sinh() [1/2]

static UE_FORCEINLINE_HINT double FGenericPlatformMath::Sinh ( double  Value)
inlinestatic

◆ Sinh() [2/2]

static UE_FORCEINLINE_HINT float FGenericPlatformMath::Sinh ( float  Value)
inlinestatic

◆ Sqrt() [1/2]

static UE_FORCEINLINE_HINT double FGenericPlatformMath::Sqrt ( double  Value)
inlinestatic

◆ Sqrt() [2/2]

static UE_FORCEINLINE_HINT float FGenericPlatformMath::Sqrt ( float  Value)
inlinestatic

◆ SRand()

float FGenericPlatformMath::SRand ( )
static

Returns a seeded random float in the range [0,1), using the seed from SRandInit().

◆ SRandInit()

void FGenericPlatformMath::SRandInit ( int32  Seed)
static

Seeds future calls to SRand()

◆ StoreHalf()

static constexpr void FGenericPlatformMath::StoreHalf ( uint16 Ptr,
float  Value 
)
inlinestaticconstexpr

◆ SubtractAndCheckForOverflow()

template<UE::CIntegral IntType>
static bool FGenericPlatformMath::SubtractAndCheckForOverflow ( IntType  A,
IntType  B,
IntType &  OutResult 
)
inlinestatic

Subtracts two integers of any integer type, checking for overflow. If there was overflow, it returns false, and OutResult may or may not be written. If there wasn't overflow, it returns true, and the result of the subtraction is written to OutResult.

◆ Tan() [1/2]

static UE_FORCEINLINE_HINT double FGenericPlatformMath::Tan ( double  Value)
inlinestatic

◆ Tan() [2/2]

static UE_FORCEINLINE_HINT float FGenericPlatformMath::Tan ( float  Value)
inlinestatic

◆ Tanh() [1/2]

static UE_FORCEINLINE_HINT double FGenericPlatformMath::Tanh ( double  Value)
inlinestatic

◆ Tanh() [2/2]

static UE_FORCEINLINE_HINT float FGenericPlatformMath::Tanh ( float  Value)
inlinestatic

◆ TruncToDouble()

static UE_FORCEINLINE_HINT double FGenericPlatformMath::TruncToDouble ( double  F)
inlinestatic

Converts a double to an integer value with truncation towards zero.

Parameters
FFloating point value to convert
Returns
Truncated integer value.

◆ TruncToFloat() [1/2]

static UE_FORCEINLINE_HINT double FGenericPlatformMath::TruncToFloat ( double  F)
inlinestatic

◆ TruncToFloat() [2/2]

static UE_FORCEINLINE_HINT float FGenericPlatformMath::TruncToFloat ( float  F)
inlinestatic

Converts a float to an integer value with truncation towards zero.

Parameters
FFloating point value to convert
Returns
Truncated integer value.

◆ TruncToInt() [1/2]

static constexpr UE_FORCEINLINE_HINT int64 FGenericPlatformMath::TruncToInt ( double  F)
inlinestaticconstexpr

◆ TruncToInt() [2/2]

static constexpr UE_FORCEINLINE_HINT int32 FGenericPlatformMath::TruncToInt ( float  F)
inlinestaticconstexpr

◆ TruncToInt32() [1/2]

static constexpr UE_FORCEINLINE_HINT int32 FGenericPlatformMath::TruncToInt32 ( double  F)
inlinestaticconstexpr

◆ TruncToInt32() [2/2]

static constexpr UE_FORCEINLINE_HINT int32 FGenericPlatformMath::TruncToInt32 ( float  F)
inlinestaticconstexpr

Converts a float to an integer with truncation towards zero.

Parameters
FFloating point value to convert
Returns
Truncated integer.

◆ TruncToInt64()

static constexpr UE_FORCEINLINE_HINT int64 FGenericPlatformMath::TruncToInt64 ( double  F)
inlinestaticconstexpr

◆ VectorLoadHalf()

static constexpr void FGenericPlatformMath::VectorLoadHalf ( float *RESTRICT  Dst,
const uint16 *RESTRICT  Src 
)
inlinestaticconstexpr

◆ VectorStoreHalf()

static constexpr void FGenericPlatformMath::VectorStoreHalf ( uint16 *RESTRICT  Dst,
const float *RESTRICT  Src 
)
inlinestaticconstexpr

◆ WideVectorLoadHalf()

static constexpr void FGenericPlatformMath::WideVectorLoadHalf ( float *RESTRICT  Dst,
const uint16 *RESTRICT  Src 
)
inlinestaticconstexpr

◆ WideVectorStoreHalf()

static constexpr void FGenericPlatformMath::WideVectorStoreHalf ( uint16 *RESTRICT  Dst,
const float *RESTRICT  Src 
)
inlinestaticconstexpr

The documentation for this struct was generated from the following files: