 # FGenericPlatformMath

## Generic implementation for most platforms

Inheritance Hierarchy

FGenericPlatformMath FClangPlatformMath

References

Syntax

struct FGenericPlatformMath

Remarks

Generic implementation for most platforms

Functions

Name Description

constexpr T

Abs

(
const T A
)

Computes absolute value in a generic way

float

Abs

(
const float A
)

Float specialization

float

Acos

(
float Value
)

float

Asin

(
float Value
)

float

Atan

(
float Value
)

float

Atan2

(
float Y,
float X
)

uint32

CeilLogTwo

(
uint32 Arg
)

Returns smallest N such that (1<=Arg. Note: 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.

float

CeilToFloat

(
float F
)

Converts a float to the nearest greater or equal integer.

int32

CeilToInt

(
float F
)

Converts a float to the nearest greater or equal integer.

float

Cos

(
float Value
)

int32

CountBits

(
uint64 Bits
)

uint32

(
uint32 Value
)

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

uint64

(
uint64 Value
)

Counts the number of leading zeros in the bit representation of the 64-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

float

Exp

(
float Value
)

Returns e^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.

int32

FloorToInt

(
float F
)

Converts a float to a nearest less or equal integer.

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.

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

float

InvSqrtEst

(
float F
)

Computes a faster but less accurate inverse square root

bool

IsFinite

(
double A
)

bool

IsFinite

(
float A
)

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

bool

IsNaN

(
double A
)

bool

IsNaN

(
float A
)

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

bool

IsNegativeDouble

(
double A
)

bool

IsNegativeFloat

(
float A
)

float

Log2

(
float Value
)

1.0 / Loge(2) = 1.4426950f

float

Loge

(
float Value
)

float

LogX

(
float Base,
float Value
)

T

Max

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

Max of Array

constexpr T

Max

(
const T A,
const T B
)

Returns higher value in a generic way

VectorRegist...

Max

(
const VectorRegister A,
const VectorRegister B
)

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

VectorRegist...

Min

(
const VectorRegister A,
const VectorRegister B
)

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

T

Min

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

Min of Array

constexpr T

Min

(
const T A,
const T B
)

Returns lower value in a generic way

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
)

uint32

MortonCode3

(
uint32 x
)

float

Pow

(
float A,
float 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()

uint32

ReverseMortonCode2

(
uint32 x
)

Reverses MortonCode2. Compacts every other bit to the right.

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

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

float

Sin

(
float Value
)

float

Sinh

(
float Value
)

float

Sqrt

(
float 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()

float

Tan

(
float 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.

constexpr in...

TruncToInt

(
float F
)

Converts a float to an integer with truncation towards zero.

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.