UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FFloat16 Class Reference

#include <Float16.h>

Public Member Functions

 FFloat16 ()=default
 
 FFloat16 (const FFloat16 &FP16Value)=default
 
 FFloat16 (float FP32Value)
 
FFloat16operator= (float FP32Value)
 
FFloat16operator= (const FFloat16 &FP16Value)=default
 
 operator float () const
 
void Set (float FP32Value)
 
void SetClamped (float FP32Value)
 
void CORE_API SetTruncate (float FP32Value)
 
void SetZero ()
 
void SetOne ()
 
FFloat16 GetClampedNonNegativeAndFinite () const
 
FFloat16 GetClampedFinite () const
 
float GetFloat () const
 
bool IsNegative () const
 

Public Attributes

uint16 Encoded = 0
 

Static Public Attributes

static constexpr float MaxF16Float = 65504.f
 

Friends

FArchiveoperator<< (FArchive &Ar, FFloat16 &V)
 

Detailed Description

16 bit float components and conversion

IEEE float 16 Represented by 10-bit mantissa M, 5-bit exponent E, and 1-bit sign S

Specials:

E=0, M=0 == 0.0 E=0, M!=0 == Denormalized value (M / 2^10) * 2^-14 0<E<31, M=any == (1 + M / 2^10) * 2^(E-15) E=31, M=0 == Infinity E=31, M!=0 == NAN

conversion from 32 bit float is with RTNE (round to nearest even)

Legacy code truncated in the conversion. SetTruncate can be used for backwards compatibility.

Constructor & Destructor Documentation

◆ FFloat16() [1/3]

FFloat16::FFloat16 ( )
default

Default constructor

◆ FFloat16() [2/3]

FFloat16::FFloat16 ( const FFloat16 FP16Value)
default

Copy constructor.

◆ FFloat16() [3/3]

UE_FORCEINLINE_HINT FFloat16::FFloat16 ( float  FP32Value)

Conversion constructor. Convert from Fp32 to Fp16.

Member Function Documentation

◆ GetClampedFinite()

FFloat16 FFloat16::GetClampedFinite ( ) const
inline

Return float clamp in [-MaxF16Float,MaxF16Float] , no infinites or nans returned

◆ GetClampedNonNegativeAndFinite()

FFloat16 FFloat16::GetClampedNonNegativeAndFinite ( ) const
inline

Return float clamp in [0,MaxF16Float] , no negatives or infinites or nans returned

◆ GetFloat()

UE_FORCEINLINE_HINT float FFloat16::GetFloat ( ) const

Convert from Fp16 to Fp32.

◆ IsNegative()

bool FFloat16::IsNegative ( ) const
inline

Is the float negative without converting NOTE: returns true for negative zero!

◆ operator float()

UE_FORCEINLINE_HINT FFloat16::operator float ( ) const

Convert from Fp16 to Fp32.

◆ operator=() [1/2]

FFloat16 & FFloat16::operator= ( const FFloat16 FP16Value)
default

Assignment operator. Copy Fp16 value.

◆ operator=() [2/2]

FFloat16 & FFloat16::operator= ( float  FP32Value)
inline

Assignment operator. Convert from Fp32 to Fp16.

◆ Set()

UE_FORCEINLINE_HINT void FFloat16::Set ( float  FP32Value)

Convert from Fp32 to Fp16, round-to-nearest-even. (RTNE) Stores values out of range as +-Inf

◆ SetClamped()

void FFloat16::SetClamped ( float  FP32Value)
inline

◆ SetOne()

void FFloat16::SetOne ( )
inline

Set to 1.0

◆ SetTruncate()

void FFloat16::SetTruncate ( float  FP32Value)

Convert from Fp32 to Fp16, truncating low bits. (backward-compatible conversion; was used by Set() previously) Clamps values out of range to [-MaxF16Float,MaxF16Float]

◆ SetZero()

void FFloat16::SetZero ( )
inline

Set to 0.0

Friends And Related Symbol Documentation

◆ operator<<

FArchive & operator<< ( FArchive Ar,
FFloat16 V 
)
friend

Serializes the FFloat16.

Parameters
ArReference to the serialization archive.
VReference to the FFloat16 being serialized.
Returns
Reference to the Archive after serialization.

Member Data Documentation

◆ Encoded

uint16 FFloat16::Encoded = 0

◆ MaxF16Float

constexpr float FFloat16::MaxF16Float = 65504.f
staticconstexpr

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