 # FGenericPlatformMath

## Generic implementation for most platforms

Inheritance Hierarchy

FGenericPlatformMath FClangPlatformMath

References

Syntax

struct FGenericPlatformMath

Remarks

Generic implementation for most platforms

Functions

Name Description

double

Abs

(
const double A
)

float

Abs

(
const float A
)

Float specialization

constexpr T

Abs

(
const T A
)

Computes absolute value in a generic way

double

Acos

(
double Value
)

float

Acos

(
float Value
)

float

AsFloat

(
uint32 U
)

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

double

AsFloat

(
uint64 U
)

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

float

Asin

(
float Value
)

double

Asin

(
double Value
)

uint32

AsUInt

(
float F
)

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

uint64

AsUInt

(
double F
)

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

float

Atan

(
float Value
)

double

Atan

(
double Value
)

float

Atan2

(
float Y,
float X
)

double

Atan2

(
double Y,
double X
)

uint32

CeilLogTwo

(
uint32 Arg
)

Returns smallest N such that (1<=Arg.

CeilLogTwo(0)=0 because (1<<0)=1 >= 0.

uint64

CeilLogTwo64

(
uint64 Arg
)

double

CeilToDouble

(
double F
)

Converts a double to the nearest greater or equal integer.

double

CeilToFloat

(
double F
)

float

CeilToFloat

(
float F
)

Converts a float to the nearest greater or equal integer.

int32

CeilToInt

(
double F
)

int32

CeilToInt

(
float F
)

Converts a float to the nearest greater or equal integer.

int64

CeilToInt64

(
double F
)

double

Cos

(
double Value
)

float

Cos

(
float Value
)

int32

CountBits

(
uint64 Bits
)

uint32

(
uint32 Value
)

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

uint64

(
uint64 Value
)

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

uint8

(
uint8 Value
)

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

uint32

CountTrailingZeros

(
uint32 Value
)

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

uint64

CountTrailingZeros64

(
uint64 Value
)

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

double

Exp

(
double Value
)

float

Exp

(
float Value
)

Returns e^Value.

double

Exp2

(
double Value
)

float

Exp2

(
float Value
)

Returns 2^Value.

constexpr fl...

FloatSelect

(
float Comparand,
float ValueGEZero,
float ValueLTZero
)

Returns value based on comparand.

constexpr do...

FloatSelect

(
double Comparand,
double ValueGEZero,
double ValueLTZero
)

Returns value based on comparand.

uint32

FloorLog2

(
uint32 Value
)

Computes the base 2 logarithm for an integer value that is greater than 0.

uint64

FloorLog2_64

(
uint64 Value
)

Computes the base 2 logarithm for a 64-bit value that is greater than 0.

double

FloorToDouble

(
double F
)

Converts a double to a less or equal integer.

float

FloorToFloat

(
float F
)

Converts a float to the nearest less or equal integer.

double

FloorToFloat

(
double F
)

int32

FloorToInt

(
float F
)

Converts a float to a nearest less or equal integer.

int32

FloorToInt

(
double F
)

int64

FloorToInt64

(
double F
)

double

Fmod

(
double X,
double Y
)

Returns the floating-point remainder of X / Y Warning: Always returns remainder toward 0, not toward the smaller multiple of Y.

float

Fmod

(
float X,
float Y
)

Returns the floating-point remainder of X / Y Warning: Always returns remainder toward 0, not toward the smaller multiple of Y.

float

Frac

(
float Value
)

Returns the fractional part of a float.

double

Frac

(
double Value
)

double

Fractional

(
double Value
)

float

Fractional

(
float Value
)

Returns signed fractional part of a float.

float

FRand()

Returns a random float between 0 and 1, inclusive.

int32

GetRandSeed()

Returns the current seed for SRand().

float

InvSqrt

(
float F
)

Computes a fully accurate inverse square root

double

InvSqrt

(
double F
)

float

InvSqrtEst

(
float F
)

Computes a faster but less accurate inverse square root

double

InvSqrtEst

(
double F
)

bool

IsFinite

(
float A
)

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

bool

IsFinite

(
double A
)

bool

IsNaN

(
float A
)

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

bool

IsNaN

(
double A
)

bool

IsNegative

(
float A
)

bool

IsNegative

(
double A
)

float

(
const uint16* Ptr
)

https://gist.github.com/rygorous/2156668

float

Log2

(
float Value
)

1.0 / Loge(2) = 1.4426950f

double

Log2

(
double Value
)

1.0 / Loge(2) = 1.442695040888963387

float

Loge

(
float Value
)

double

Loge

(
double Value
)

float

LogX

(
float Base,
float Value
)

double

LogX

(
double Base,
double Value
)

constexpr T

Max

(
const T A,
const T B
)

Returns higher value in a generic way

constexpr do...

Max

(
const double A,
const float B
)

LWC_TODO: Simplify code refactoring to avoid double/float mismatches. Should not ship?

T

Max

(
const TArray< T >& Values,
int32* MaxIndex
)

Max of Array

VectorRegist...

Max

(
const VectorRegister4Float A,
const VectorRegister4Float B
)

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

VectorRegist...

Max

(
const VectorRegister4Double A,
const VectorRegister4Double B
)

constexpr do...

Max

(
const float A,
const double B
)

VectorRegist...

Min

(
const VectorRegister4Double A,
const VectorRegister4Double B
)

constexpr T

Min

(
const T A,
const T B
)

Returns lower value in a generic way

constexpr do...

Min

(
const double A,
const float B
)

constexpr do...

Min

(
const float A,
const double B
)

T

Min

(
const TArray< T >& Values,
int32* MinIndex
)

Min of Array

VectorRegist...

Min

(
const VectorRegister4Float A,
const VectorRegister4Float B
)

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

double

Modf

(
const double InValue,
double* OutIntPart
)

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

float

Modf

(
const float InValue,
float* OutIntPart
)

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

uint32

MortonCode2

(
uint32 x
)

uint64

MortonCode2_64

(
uint64 x
)

uint32

MortonCode3

(
uint32 x
)

float

Pow

(
float A,
float B
)

double

Pow

(
double A,
double B
)

int32

Rand()

Returns a random integer between 0 and RAND_MAX, inclusive

void

RandInit

(
int32 Seed
)

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

RESOLVE_FLOAT_AMBIGUITY

RESOLVE_FLOAT_AMBIGUITY

RESOLVE_FLOAT_AMBIGUITY

(
Frac
)

RESOLVE_FLOAT_AMBIGUITY

(
Loge
)

RESOLVE_FLOAT_AMBIGUITY

(
Exp2
)

RESOLVE_FLOAT_AMBIGUITY

(
Log2
)

RESOLVE_FLOAT_AMBIGUITY

(
Asin
)

RESOLVE_FLOAT_AMBIGUITY

(
Sinh
)

RESOLVE_FLOAT_AMBIGUITY

(
Cos
)

RESOLVE_FLOAT_AMBIGUITY

(
Acos
)

RESOLVE_FLOAT_AMBIGUITY

(
Tan
)

RESOLVE_FLOAT_AMBIGUITY

(
Atan
)

RESOLVE_FLOAT_AMBIGUITY

(
Sqrt
)

RESOLVE_FLOAT_AMBIGUITY

(
InvSqrt
)

RESOLVE_FLOAT_AMBIGUITY

RESOLVE_FLOAT_AMBIGUITY

(
Exp
)

RESOLVE_FLOAT_AMBIGUITY

RESOLVE_FLOAT_AMBIGUITY

RESOLVE_FLOAT_AMBIGUITY

RESOLVE_FLOAT_AMBIGUITY_2_ARGS

(
Pow
)

RESOLVE_FLOAT_AMBIGUITY_2_ARGS

(
Atan2
)

RESOLVE_FLOAT_AMBIGUITY_2_ARGS

(
Fmod
)

RESOLVE_FLOAT_AMBIGUITY_2_ARGS

(
LogX
)

RESOLVE_FLOAT_TO_TYPE_AMBIGUITY

RESOLVE_FLOAT_TO_TYPE_AMBIGUITY

RESOLVE_FLOAT_TO_TYPE_AMBIGUITY

uint32

ReverseMortonCode2

(
uint32 x
)

Reverses MortonCode2. Compacts every other bit to the right.

uint64

ReverseMortonCode2_64

(
uint64 x
)

uint32

ReverseMortonCode3

(
uint32 x
)

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

double

RoundToDouble

(
double F
)

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

double

RoundToFloat

(
double F
)

float

RoundToFloat

(
float F
)

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

int32

RoundToInt

(
float F
)

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

uint32

RoundUpToPowerOfTwo

(
uint32 Arg
)

uint64

RoundUpToPowerOfTwo64

(
uint64 V
)

constexpr T

Sign

(
const T A
)

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

double

Sin

(
double Value
)

float

Sin

(
float Value
)

double

Sinh

(
double Value
)

float

Sinh

(
float Value
)

float

Sqrt

(
float Value
)

double

Sqrt

(
double Value
)

float

SRand()

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

void

SRandInit

(
int32 Seed
)

Seeds future calls to SRand()

void

StoreHalf

(
uint16* Ptr,
float Value
)

https://gist.github.com/rygorous/2156668 float_to_half_fast3_rtne

float

Tan

(
float Value
)

double

Tan

(
double Value
)

double

TruncToDouble

(
double F
)

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

float

TruncToFloat

(
float F
)

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

double

TruncToFloat

(
double F
)

constexpr in...

TruncToInt

(
double F
)

constexpr in...

TruncToInt

(
float F
)

Converts a float to an integer with truncation towards zero.

void

(
float*restrict Dst,
const uint16*
restrict Src
)

void

VectorStoreHalf

(
uint16*restrict Dst,
const float*
restrict Src
)

void

(
float*restrict Dst,
const uint16*
restrict Src
)

void

WideVectorStoreHalf

(
uint16*restrict Dst,
const float*
restrict Src
)

Classes

Name

Description

TIsSameOrNotFP

Temporary support for ambiguities to simplify UE4 -> UE5 upgrades - falls back to float variant.

Constants

Name

Description

TIsAmbiguous

Deprecated Functions

Name Description

bool

IsNegativeDouble

(
double A
)

Use IsNegative here.

bool

IsNegativeFloat

(
float A
)

Use IsNegative here.