Navigation
API > API/Runtime > API/Runtime/Core
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
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.
| Name | FFloat16 |
| Type | class |
| Header File | /Engine/Source/Runtime/Core/Public/Math/Float16.h |
| Include Path | #include "Math/Float16.h" |
Syntax
class FFloat16
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
FFloat16 () |
Default constructor | Math/Float16.h | |
| Copy constructor. | Math/Float16.h | ||
FFloat16
(
float FP32Value |
Conversion constructor. Convert from Fp32 to Fp16. | Math/Float16.h |
Constants
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| MaxF16Float | float | Float16 can store values in [-MaxF16Float,MaxF16Float] | Math/Float16.h |
Variables
Public
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| Encoded | uint16 | Math/Float16.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
FFloat16 GetClampedFinite() |
Return float clamp in [-MaxF16Float,MaxF16Float] , no infinites or nans returned | Math/Float16.h | |
FFloat16 GetClampedNonNegativeAndFinite() |
Return float clamp in [0,MaxF16Float] , no negatives or infinites or nans returned | Math/Float16.h | |
float GetFloat() |
Convert from Fp16 to Fp32. | Math/Float16.h | |
bool IsNegative() |
Is the float negative without converting NOTE: returns true for negative zero! | Math/Float16.h | |
void Set
(
float FP32Value |
NOTE: Set() on values out of F16 max range store them as +-Inf. | Math/Float16.h | |
void SetClamped
(
float FP32Value |
Convert from Fp32 to Fp16, round-to-nearest-even. | Math/Float16.h | |
void SetOne() |
Set to 1.0 | Math/Float16.h | |
void SetTruncate
(
float FP32Value |
NOTE: SetTruncate() on values out of F16 max range store them as +-Inf. | Math/Float16.h | |
void SetZero() |
Set to 0.0 | Math/Float16.h |
Operators
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
operator float() |
Convert from Fp16 to Fp32. | Math/Float16.h | |
| Assignment operator. Convert from Fp32 to Fp16. | Math/Float16.h | ||
| Assignment operator. Copy Fp16 value. | Math/Float16.h |