FGenericPlatformMath

Generic implementation for most platforms

Windows
MacOS
Linux

Inheritance Hierarchy

FGenericPlatformMath

FClangPlatformMath

References

Module

Core

Header

/Engine/Source/Runtime/Core/Public/GenericPlatform/GenericPlatformMath.h

Include

#include "GenericPlatform/GenericPlatformMath.h"

Syntax

struct FGenericPlatformMath

Remarks

Generic implementation for most platforms

Functions

Name Description

Public function Static

constexpr T

 

Abs

(
    const T A
)

Computes absolute value in a generic way

Public function

float

 

Abs

(
    const float A
)

Float specialization

Public function Static

float

 

Acos

(
    float Value
)

Public function Static

float

 

Asin

(
    float Value
)

Public function Static

float

 

Atan

(
    float Value
)

Public function Static

float

 

Atan2

(
    float Y,
    float X
)

Public function Static

uint32

 

CeilLogTwo

(
    uint32 Arg
)

Returns smallest N such that (1<=Arg.

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

Public function Static

uint64

 

CeilLogTwo64

(
    uint64 Arg
)

Public function Static

double

 

CeilToDouble

(
    double F
)

Converts a double to the nearest greater or equal integer.

Public function Static

float

 

CeilToFloat

(
    float F
)

Converts a float to the nearest greater or equal integer.

Public function Static

int32

 

CeilToInt

(
    float F
)

Converts a float to the nearest greater or equal integer.

Public function Static

float

 

Cos

(
    float Value
)

Public function Static

int32

 

CountBits

(
    uint64 Bits
)

Public function Static

uint32

 

CountLeadingZeros

(
    uint32 Value
)

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

Public function Static

uint64

 

CountLeadingZeros64

(
    uint64 Value
)

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

Public function Static

uint8

 

CountLeadingZeros8

(
    uint8 Value
)

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

Public function Static

uint32

 

CountTrailingZeros

(
    uint32 Value
)

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

Public function Static

uint64

 

CountTrailingZeros64

(
    uint64 Value
)

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

Public function Static

float

 

Exp

(
    float Value
)

Returns e^Value.

Public function Static

float

 

Exp2

(
    float Value
)

Returns 2^Value.

Public function Static

constexpr fl...

 

FloatSelect

(
    float Comparand,
    float ValueGEZero,
    float ValueLTZero
)

Returns value based on comparand.

Public function Static

constexpr do...

 

FloatSelect

(
    double Comparand,
    double ValueGEZero,
    double ValueLTZero
)

Returns value based on comparand.

Public function Static

uint32

 

FloorLog2

(
    uint32 Value
)

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

Public function Static

uint64

 

FloorLog2_64

(
    uint64 Value
)

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

Public function Static

double

 

FloorToDouble

(
    double F
)

Converts a double to a less or equal integer.

Public function Static

float

 

FloorToFloat

(
    float F
)

Converts a float to the nearest less or equal integer.

Public function Static

int32

 

FloorToInt

(
    float F
)

Converts a float to a nearest less or equal integer.

Public function Static

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.

Public function Static

float

 

Frac

(
    float Value
)

Returns the fractional part of a float.

Public function Static

float

 

Fractional

(
    float Value
)

Returns signed fractional part of a float.

Public function Static

float

 

FRand()

Returns a random float between 0 and 1, inclusive.

Public function Static

int32

 

GetRandSeed()

Returns the current seed for SRand().

Public function Static

float

 

InvSqrt

(
    float F
)

Computes a fully accurate inverse square root

Public function Static

float

 

InvSqrtEst

(
    float F
)

Computes a faster but less accurate inverse square root

Public function Static

bool

 

IsFinite

(
    double A
)

Public function Static

bool

 

IsFinite

(
    float A
)

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

Public function Static

bool

 

IsNaN

(
    double A
)

Public function Static

bool

 

IsNaN

(
    float A
)

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

Public function Static

bool

 

IsNegativeDouble

(
    double A
)

Public function Static

bool

 

IsNegativeFloat

(
    float A
)

Public function Static

float

 

LoadHalf

(
    const uint16* Ptr
)

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

Public function Static

float

 

Log2

(
    float Value
)

1.0 / Loge(2) = 1.4426950f

Public function Static

float

 

Loge

(
    float Value
)

Public function Static

float

 

LogX

(
    float Base,
    float Value
)

Public function Static

T

 

Max

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

Max of Array

Public function Static

constexpr T

 

Max

(
    const T A,
    const T B
)

Returns higher value in a generic way

Public function

VectorRegist...

 

Max

(
    const VectorRegister A,
    const VectorRegister B
)

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

Public function

VectorRegist...

 

Min

(
    const VectorRegister A,
    const VectorRegister B
)

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

Public function Static

T

 

Min

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

Min of Array

Public function Static

constexpr T

 

Min

(
    const T A,
    const T B
)

Returns lower value in a generic way

Public function Static

double

 

Modf

(
    const double InValue,
    double* OutIntPart
)

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

Public function Static

float

 

Modf

(
    const float InValue,
    float* OutIntPart
)

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

Public function Static

uint32

 

MortonCode2

(
    uint32 x
)

Spreads bits to every other.

Public function Static

uint64

 

MortonCode2_64

(
    uint64 x
)

Public function Static

uint32

 

MortonCode3

(
    uint32 x
)

Spreads bits to every 3rd.

Public function Static

float

 

Pow

(
    float A,
    float B
)

Public function Static

int32

 

Rand()

Returns a random integer between 0 and RAND_MAX, inclusive

Public function Static

void

 

RandInit

(
    int32 Seed
)

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

Public function Static

uint32

 

ReverseMortonCode2

(
    uint32 x
)

Reverses MortonCode2. Compacts every other bit to the right.

Public function Static

uint64

 

ReverseMortonCode2_64

(
    uint64 x
)

Public function Static

uint32

 

ReverseMortonCode3

(
    uint32 x
)

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

Public function Static

double

 

RoundToDouble

(
    double F
)

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

Public function Static

float

 

RoundToFloat

(
    float F
)

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

Public function Static

int32

 

RoundToInt

(
    float F
)

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

Public function Static

uint32

 

RoundUpToPowerOfTwo

(
    uint32 Arg
)

Public function Static

uint64

 

RoundUpToPowerOfTwo64

(
    uint64 V
)

Public function Static

constexpr T

 

Sign

(
    const T A
)

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

Public function Static

float

 

Sin

(
    float Value
)

Public function Static

float

 

Sinh

(
    float Value
)

Public function Static

float

 

Sqrt

(
    float Value
)

Public function Static

float

 

SRand()

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

Public function Static

void

 

SRandInit

(
    int32 Seed
)

Seeds future calls to SRand()

Public function Static

void

 

StoreHalf

(
    uint16* Ptr,
    float Value
)

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

Public function Static

float

 

Tan

(
    float Value
)

Public function Static

double

 

TruncToDouble

(
    double F
)

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

Public function Static

float

 

TruncToFloat

(
    float F
)

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

Public function Static

constexpr in...

 

TruncToInt

(
    float F
)

Converts a float to an integer with truncation towards zero.

Public function Static

void

 

VectorLoadHalf

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

Public function Static

void

 

VectorStoreHalf

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

Public function Static

void

 

WideVectorLoadHalf

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

Public function Static

void

 

WideVectorStoreHalf

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

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