6#include "Serialization/Archive.h"
7#include "Math/UnrealMathUtility.h"
8#include "Math/Float32.h"
9#include "Serialization/MemoryLayout.h"
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
61
62 void Set(
float FP32Value);
65
72
73
98
107
108
109
110
111
112
113
164 FPlatformMath::StoreHalf(&Encoded, FP32Value);
171 return FPlatformMath::LoadHalf(&Encoded);
184 uint16 Mantissa : 10;
190 uint16 Mantissa : 10;
201 FP16.Components.Sign = FP32.Components.Sign;
204 if (FP32.Components.Exponent <= 112)
207 FP16.Components.Exponent = 0;
208 FP16.Components.Mantissa = 0;
211 const int32 NewExp = FP32.Components.Exponent - 127 + 15;
213 if ( (14 - NewExp) <= 24 )
215 uint32 Mantissa = FP32.Components.Mantissa | 0x800000;
216 FP16.Components.Mantissa = (uint16)(Mantissa >> (14 - NewExp));
218 if ( (Mantissa >> (13 - NewExp)) & 1 )
225 else if (FP32.Components.Exponent >= 143)
228 FP16.Components.Exponent = 30;
229 FP16.Components.Mantissa = 1023;
234 FP16.Components.Exponent = uint16(int32(FP32.Components.Exponent) - 127 + 15);
235 FP16.Components.Mantissa = uint16(FP32.Components.Mantissa >> 13);
262 if ( (
Encoded&0x7c00) == 0x7c00 )
#define DECLARE_INTRINSIC_TYPE_LAYOUT(T)
FFloat16 GetClampedNonNegativeAndFinite() const
static constexpr float MaxF16Float
void Set(float FP32Value)
void SetClamped(float FP32Value)
FFloat16 GetClampedFinite() const
FFloat16 & operator=(const FFloat16 &FP16Value)
FFloat16 & operator=(float FP32Value)
FFloat16(const FFloat16 &FP16Value)
void SetTruncate(float FP32Value)
FFloat16(float FP32Value)
FFloat32(float InValue=0.0f)
static UE_NODISCARD constexpr FORCEINLINE float Clamp(const float X, const float Min, const float Max)