Navigation
API > API/Runtime > API/Runtime/Core
Generic implementation for most platforms
| Name | FGenericPlatformMath |
| Type | struct |
| Header File | /Engine/Source/Runtime/Core/Public/GenericPlatform/GenericPlatformMath.h |
| Include Path | #include "GenericPlatform/GenericPlatformMath.h" |
Syntax
struct FGenericPlatformMath
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
double Abs
(
const double A |
GenericPlatform/GenericPlatformMath.h | ||
float Abs
(
const float A |
Float specialization | GenericPlatform/GenericPlatformMath.h | |
| Returns the larger of the two values (operates on each component individually) | |||
| Returns the smaller of the two values (operates on each component individually) | |||
Static
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
static T Abs
(
const T A |
Computes absolute value in a generic way | GenericPlatform/GenericPlatformMath.h | |
static float Acos
(
float Value |
GenericPlatform/GenericPlatformMath.h | ||
static double Acos
(
double Value |
GenericPlatform/GenericPlatformMath.h | ||
static bool AddAndCheckForOverflow
(
IntType A, |
Adds two integers of any integer type, checking for overflow. | GenericPlatform/GenericPlatformMath.h | |
static float AsFloat
(
uint32 U |
Performs a bit cast of the given unsigned int to float of the same bit width. | GenericPlatform/GenericPlatformMath.h | |
static double AsFloat
(
uint64 U |
Performs a bit cast of the given unsigned int to float of the same bit width. | GenericPlatform/GenericPlatformMath.h | |
static float Asin
(
float Value |
GenericPlatform/GenericPlatformMath.h | ||
static double Asin
(
double Value |
GenericPlatform/GenericPlatformMath.h | ||
static uint32 AsUInt
(
float F |
Performs a bit cast of the given float to an unsigned int of the same bit width. | GenericPlatform/GenericPlatformMath.h | |
static uint64 AsUInt
(
double D |
Performs a bit cast of the given double to an unsigned int of the same bit width. | GenericPlatform/GenericPlatformMath.h | |
static float Atan
(
float Value |
GenericPlatform/GenericPlatformMath.h | ||
static double Atan
(
double Value |
GenericPlatform/GenericPlatformMath.h | ||
static float Atan2
(
float Y, |
GenericPlatform/GenericPlatformMath.h | ||
static double Atan2
(
double Y, |
GenericPlatform/GenericPlatformMath.h | ||
static decltype(X *Y) Atan2
(
Arg1 X, |
GenericPlatform/GenericPlatformMath.h | ||
static uint32 CeilLogTwo
(
uint32 Arg |
Returns smallest N such that (1< |
GenericPlatform/GenericPlatformMath.h | |
static uint64 CeilLogTwo64
(
uint64 Arg |
GenericPlatform/GenericPlatformMath.h | ||
static double CeilToDouble
(
double F |
Converts a double to the nearest greater or equal integer. | GenericPlatform/GenericPlatformMath.h | |
static double CeilToFloat
(
double F |
GenericPlatform/GenericPlatformMath.h | ||
static float CeilToFloat
(
float F |
Converts a float to the nearest greater or equal integer. | GenericPlatform/GenericPlatformMath.h | |
static int32 CeilToInt
(
float F |
GenericPlatform/GenericPlatformMath.h | ||
static int64 CeilToInt
(
double F |
GenericPlatform/GenericPlatformMath.h | ||
static int32 CeilToInt32
(
double F |
GenericPlatform/GenericPlatformMath.h | ||
static int32 CeilToInt32
(
float F |
Converts a float to the nearest greater or equal integer. | GenericPlatform/GenericPlatformMath.h | |
static int64 CeilToInt64
(
double F |
GenericPlatform/GenericPlatformMath.h | ||
static uint8 ConstExprCeilLogTwo
(
SIZE_T Arg |
Returns the smallest N such that (1< |
GenericPlatform/GenericPlatformMath.h | |
static double CopySign
(
double X, |
GenericPlatform/GenericPlatformMath.h | ||
static decltype(X *Y) CopySign
(
Arg1 X, |
GenericPlatform/GenericPlatformMath.h | ||
static float CopySign
(
float X, |
Composes a floating-point value with the magnitude of X and the sign of Y. | GenericPlatform/GenericPlatformMath.h | |
static float Cos
(
float Value |
GenericPlatform/GenericPlatformMath.h | ||
static double Cos
(
double Value |
GenericPlatform/GenericPlatformMath.h | ||
static float Cosh
(
float Value |
GenericPlatform/GenericPlatformMath.h | ||
static double Cosh
(
double Value |
GenericPlatform/GenericPlatformMath.h | ||
static int32 CountBits
(
uint64 Bits |
GenericPlatform/GenericPlatformMath.h | ||
static uint32 CountLeadingZeros
(
uint32 Value |
Counts the number of leading zeros in the bit representation of the 32-bit value | GenericPlatform/GenericPlatformMath.h | |
static uint64 CountLeadingZeros64
(
uint64 Value |
Counts the number of leading zeros in the bit representation of the 64-bit value | GenericPlatform/GenericPlatformMath.h | |
static uint8 CountLeadingZeros8
(
uint8 Value |
Counts the number of leading zeros in the bit representation of the 8-bit value | GenericPlatform/GenericPlatformMath.h | |
static uint32 CountTrailingZeros
(
uint32 Value |
Counts the number of trailing zeros in the bit representation of the value | GenericPlatform/GenericPlatformMath.h | |
static uint64 CountTrailingZeros64
(
uint64 Value |
Counts the number of trailing zeros in the bit representation of the value | GenericPlatform/GenericPlatformMath.h | |
static uint64 CountTrailingZeros64ConstExpr
(
uint64 Value |
GenericPlatform/GenericPlatformMath.h | ||
static uint32 CountTrailingZerosConstExpr
(
uint32 Value |
GenericPlatform/GenericPlatformMath.h | ||
static float Exp
(
float Value |
Returns e^Value. | GenericPlatform/GenericPlatformMath.h | |
static double Exp
(
double Value |
GenericPlatform/GenericPlatformMath.h | ||
static double Exp2
(
double Value |
GenericPlatform/GenericPlatformMath.h | ||
static float Exp2
(
float Value |
Returns 2^Value. | GenericPlatform/GenericPlatformMath.h | |
static double FloatSelect
(
double Comparand, |
Returns value based on comparand. | GenericPlatform/GenericPlatformMath.h | |
static float FloatSelect
(
float Comparand, |
Returns value based on comparand. | GenericPlatform/GenericPlatformMath.h | |
static uint32 FloorLog2
(
uint32 Value |
Computes the base 2 logarithm for an integer value. | GenericPlatform/GenericPlatformMath.h | |
static uint64 FloorLog2_64
(
uint64 Value |
Computes the base 2 logarithm for a 64-bit value. | GenericPlatform/GenericPlatformMath.h | |
static uint32 FloorLog2NonZero
(
uint32 Value |
FloorLog2 but the caller guarantees that Value is not 0. | GenericPlatform/GenericPlatformMath.h | |
static uint64 FloorLog2NonZero_64
(
uint64 Value |
FloorLog2_64 but the caller guarantees that Value is not 0. | GenericPlatform/GenericPlatformMath.h | |
static double FloorToDouble
(
double F |
Converts a double to a less or equal integer. | GenericPlatform/GenericPlatformMath.h | |
static float FloorToFloat
(
float F |
Converts a float to the nearest less or equal integer. | GenericPlatform/GenericPlatformMath.h | |
static double FloorToFloat
(
double F |
GenericPlatform/GenericPlatformMath.h | ||
static int32 FloorToInt
(
float F |
GenericPlatform/GenericPlatformMath.h | ||
static int64 FloorToInt
(
double F |
GenericPlatform/GenericPlatformMath.h | ||
static int32 FloorToInt32
(
float F |
Converts a float to a nearest less or equal integer. | GenericPlatform/GenericPlatformMath.h | |
static int32 FloorToInt32
(
double F |
GenericPlatform/GenericPlatformMath.h | ||
static int64 FloorToInt64
(
double F |
GenericPlatform/GenericPlatformMath.h | ||
static float Fmod
(
float X, |
Returns the floating-point remainder of X / Y Warning: Always returns remainder toward 0, not toward the smaller multiple of Y. | GenericPlatform/GenericPlatformMath.h | |
static double Fmod
(
double X, |
GenericPlatform/GenericPlatformMath.h | ||
static decltype(X *Y) Fmod
(
Arg1 X, |
GenericPlatform/GenericPlatformMath.h | ||
static void FmodReportError
(
float X, |
Error reporting for Fmod. | GenericPlatform/GenericPlatformMath.h | |
static void FmodReportError
(
double X, |
GenericPlatform/GenericPlatformMath.h | ||
static float Frac
(
float Value |
Returns the fractional part of a float. | GenericPlatform/GenericPlatformMath.h | |
static double Frac
(
double Value |
GenericPlatform/GenericPlatformMath.h | ||
static float Fractional
(
float Value |
Returns signed fractional part of a float. | GenericPlatform/GenericPlatformMath.h | |
static double Fractional
(
double Value |
GenericPlatform/GenericPlatformMath.h | ||
static float FRand() |
Returns a random float between 0 and 1, inclusive. | GenericPlatform/GenericPlatformMath.h | |
static void GetMinMax
(
T& Min, |
Sort input values to be Min and Max | GenericPlatform/GenericPlatformMath.h | |
static void GetMinMax
(
const T& A, |
Sort input A & B values into OutMin & OutMax | GenericPlatform/GenericPlatformMath.h | |
static int32 GetRandSeed() |
Returns the current seed for SRand(). | GenericPlatform/GenericPlatformMath.h | |
static float InvSqrt
(
float F |
Computes a fully accurate inverse square root | GenericPlatform/GenericPlatformMath.h | |
static double InvSqrt
(
double F |
GenericPlatform/GenericPlatformMath.h | ||
static double InvSqrtEst
(
double F |
GenericPlatform/GenericPlatformMath.h | ||
static float InvSqrtEst
(
float F |
Computes a faster but less accurate inverse square root | GenericPlatform/GenericPlatformMath.h | |
static bool IsFinite
(
double A |
GenericPlatform/GenericPlatformMath.h | ||
static bool IsFinite
(
float A |
Return true if value is finite (not NaN and not Infinity). | GenericPlatform/GenericPlatformMath.h | |
static bool IsNaN
(
double A |
GenericPlatform/GenericPlatformMath.h | ||
static bool IsNaN
(
float A |
Return true if value is NaN (not a number). | GenericPlatform/GenericPlatformMath.h | |
static bool IsNegative
(
double A |
GenericPlatform/GenericPlatformMath.h | ||
static bool IsNegative
(
float A |
GenericPlatform/GenericPlatformMath.h | ||
static bool IsNegativeDouble
(
double A |
GenericPlatform/GenericPlatformMath.h | ||
static bool IsNegativeFloat
(
float A |
GenericPlatform/GenericPlatformMath.h | ||
static bool IsNegativeOrNegativeZero
(
double A |
GenericPlatform/GenericPlatformMath.h | ||
static bool IsNegativeOrNegativeZero
(
float A |
GenericPlatform/GenericPlatformMath.h | ||
static float LoadHalf
(
const uint16* Ptr |
Load half (F16) to float https://gist.github.com/rygorous/2156668 | GenericPlatform/GenericPlatformMath.h | |
static double Log2
(
double Value |
1.0 / Loge(2) = 1.442695040888963387 | GenericPlatform/GenericPlatformMath.h | |
static float Log2
(
float Value |
1.0 / Loge(2) = 1.4426950f | GenericPlatform/GenericPlatformMath.h | |
static double Loge
(
double Value |
GenericPlatform/GenericPlatformMath.h | ||
static float Loge
(
float Value |
GenericPlatform/GenericPlatformMath.h | ||
static decltype(X *Y) LogX
(
Arg1 X, |
GenericPlatform/GenericPlatformMath.h | ||
static double LogX
(
double Base, |
GenericPlatform/GenericPlatformMath.h | ||
static float LogX
(
float Base, |
GenericPlatform/GenericPlatformMath.h | ||
static decltype(X *Y) Max
(
Arg1 X, |
Allow mixing of float types to promote to highest precision type. | GenericPlatform/GenericPlatformMath.h | |
| Max of Array | GenericPlatform/GenericPlatformMath.h | ||
static decltype(X *Y) Max
(
Arg1 X, |
Allow mixing of signed integral types. | GenericPlatform/GenericPlatformMath.h | |
static T Max
(
T A, |
GenericPlatform/GenericPlatformMath.h | ||
static T Max
(
T A, |
Returns higher value in a generic way | GenericPlatform/GenericPlatformMath.h | |
| Max of Array | GenericPlatform/GenericPlatformMath.h | ||
static T Min
(
T A, |
GenericPlatform/GenericPlatformMath.h | ||
static T Min
(
T A, |
Returns lower value in a generic way | GenericPlatform/GenericPlatformMath.h | |
| Min of Array | GenericPlatform/GenericPlatformMath.h | ||
| Min of Array | GenericPlatform/GenericPlatformMath.h | ||
static decltype(X *Y) Min
(
Arg1 X, |
GenericPlatform/GenericPlatformMath.h | ||
static decltype(X *Y) Min
(
Arg1 X, |
GenericPlatform/GenericPlatformMath.h | ||
static double Modf
(
const double InValue, |
Breaks the given value into an integral and a fractional part. | GenericPlatform/GenericPlatformMath.h | |
static float Modf
(
const float InValue, |
Breaks the given value into an integral and a fractional part. | GenericPlatform/GenericPlatformMath.h | |
static uint32 MortonCode2
(
uint32 x |
Spreads bits to every other. | GenericPlatform/GenericPlatformMath.h | |
static uint64 MortonCode2_64
(
uint64 x |
GenericPlatform/GenericPlatformMath.h | ||
static uint32 MortonCode3
(
uint32 x |
Spreads bits to every 3rd. | GenericPlatform/GenericPlatformMath.h | |
static bool MultiplyAndCheckForOverflow
(
IntType A, |
Multiplies two integers of any integer type, checking for overflow. | GenericPlatform/GenericPlatformMath.h | |
static decltype(X *Y) Pow
(
Arg1 X, |
GenericPlatform/GenericPlatformMath.h | ||
static double Pow
(
double A, |
GenericPlatform/GenericPlatformMath.h | ||
static float Pow
(
float A, |
GenericPlatform/GenericPlatformMath.h | ||
static int32 Rand() |
Returns a random integer between 0 and RAND_MAX, inclusive | GenericPlatform/GenericPlatformMath.h | |
static int32 Rand32 () |
Returns a random integer between 0 and MAX_int32, inclusive. | GenericPlatform/GenericPlatformMath.h | |
static void RandInit
(
int32 Seed |
Seeds global random number functions Rand() and FRand() | GenericPlatform/GenericPlatformMath.h | |
static uint32 ReverseMortonCode2
(
uint32 x |
Reverses MortonCode2. Compacts every other bit to the right. | GenericPlatform/GenericPlatformMath.h | |
static uint64 ReverseMortonCode2_64
(
uint64 x |
GenericPlatform/GenericPlatformMath.h | ||
static uint32 ReverseMortonCode3
(
uint32 x |
Reverses MortonCode3. Compacts every 3rd bit to the right. | GenericPlatform/GenericPlatformMath.h | |
static double RoundToDouble
(
double F |
Converts a double to the nearest integer. Rounds up when the fraction is .5 | GenericPlatform/GenericPlatformMath.h | |
static float RoundToFloat
(
float F |
Converts a float to the nearest integer. Rounds up when the fraction is .5 | GenericPlatform/GenericPlatformMath.h | |
static double RoundToFloat
(
double F |
GenericPlatform/GenericPlatformMath.h | ||
static int32 RoundToInt
(
float F |
GenericPlatform/GenericPlatformMath.h | ||
static int64 RoundToInt
(
double F |
GenericPlatform/GenericPlatformMath.h | ||
static int32 RoundToInt32
(
float F |
Converts a float to the nearest integer. Rounds up when the fraction is .5 | GenericPlatform/GenericPlatformMath.h | |
static int32 RoundToInt32
(
double F |
GenericPlatform/GenericPlatformMath.h | ||
static int64 RoundToInt64
(
double F |
GenericPlatform/GenericPlatformMath.h | ||
static int64 RoundToNearestTiesToEven
(
double F |
Converts a double to nearest int64 with ties rounding to nearest even May incur a performance penalty. | GenericPlatform/GenericPlatformMath.h | |
static uint32 RoundUpToPowerOfTwo
(
uint32 Arg |
GenericPlatform/GenericPlatformMath.h | ||
static uint64 RoundUpToPowerOfTwo64
(
uint64 V |
GenericPlatform/GenericPlatformMath.h | ||
static T Sign
(
const T A |
Returns 1, 0, or -1 depending on relation of T to 0 | GenericPlatform/GenericPlatformMath.h | |
static float Sin
(
float Value |
GenericPlatform/GenericPlatformMath.h | ||
static double Sin
(
double Value |
GenericPlatform/GenericPlatformMath.h | ||
static double Sinh
(
double Value |
GenericPlatform/GenericPlatformMath.h | ||
static float Sinh
(
float Value |
GenericPlatform/GenericPlatformMath.h | ||
static double Sqrt
(
double Value |
GenericPlatform/GenericPlatformMath.h | ||
static float Sqrt
(
float Value |
GenericPlatform/GenericPlatformMath.h | ||
static float SRand() |
Returns a seeded random float in the range [0,1), using the seed from SRandInit(). | GenericPlatform/GenericPlatformMath.h | |
static void SRandInit
(
int32 Seed |
Seeds future calls to SRand() | GenericPlatform/GenericPlatformMath.h | |
static void StoreHalf
(
uint16* Ptr, |
Store float to half (F16) converts with RTNE = round to nearest even values too large for F16 are stored as +-Inf https://gist.github.com/rygorous/2156668 float_to_half_fast3_rtne | GenericPlatform/GenericPlatformMath.h | |
static bool SubtractAndCheckForOverflow
(
IntType A, |
Subtracts two integers of any integer type, checking for overflow. | GenericPlatform/GenericPlatformMath.h | |
static float Tan
(
float Value |
GenericPlatform/GenericPlatformMath.h | ||
static double Tan
(
double Value |
GenericPlatform/GenericPlatformMath.h | ||
static float Tanh
(
float Value |
GenericPlatform/GenericPlatformMath.h | ||
static double Tanh
(
double Value |
GenericPlatform/GenericPlatformMath.h | ||
static double TruncToDouble
(
double F |
Converts a double to an integer value with truncation towards zero. | GenericPlatform/GenericPlatformMath.h | |
static double TruncToFloat
(
double F |
GenericPlatform/GenericPlatformMath.h | ||
static float TruncToFloat
(
float F |
Converts a float to an integer value with truncation towards zero. | GenericPlatform/GenericPlatformMath.h | |
static int32 TruncToInt
(
float F |
GenericPlatform/GenericPlatformMath.h | ||
static int64 TruncToInt
(
double F |
GenericPlatform/GenericPlatformMath.h | ||
static int32 TruncToInt32
(
double F |
GenericPlatform/GenericPlatformMath.h | ||
static int32 TruncToInt32
(
float F |
Converts a float to an integer with truncation towards zero. | GenericPlatform/GenericPlatformMath.h | |
static int64 TruncToInt64
(
double F |
GenericPlatform/GenericPlatformMath.h | ||
static void VectorLoadHalf
(
float*__restrict Dst, |
GenericPlatform/GenericPlatformMath.h | ||
static void VectorStoreHalf
(
uint16*__restrict Dst, |
GenericPlatform/GenericPlatformMath.h | ||
static void WideVectorLoadHalf
(
float*__restrict Dst, |
GenericPlatform/GenericPlatformMath.h | ||
static void WideVectorStoreHalf
(
uint16*__restrict Dst, |
GenericPlatform/GenericPlatformMath.h |