MCPcopy Create free account
hub / github.com/catboost/catboost / TFloat16

Class TFloat16

library/cpp/float16/float16.h:47–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45}
46
47struct TFloat16 {
48 using TStorageType = ui16;
49
50 TStorageType Data = 0;
51
52 constexpr TFloat16() {}
53
54 TFloat16(float v) {
55 Data = NFloat16Impl::ConvertFloat32IntoFloat16Auto(v);
56 }
57
58 TFloat16(const TFloat16&) = default;
59
60 TFloat16& operator=(const TFloat16&) = default;
61 TFloat16& operator=(float v) {
62 Data = NFloat16Impl::ConvertFloat32IntoFloat16Auto(v);
63 return *this;
64 }
65
66 Y_PURE_FUNCTION
67 float AsFloat() const {
68 return NFloat16Impl::ConvertFloat16IntoFloat32Auto(Data);
69 }
70
71 Y_CONST_FUNCTION
72 static constexpr TFloat16 Load(TStorageType d) {
73 TFloat16 res;
74 res.Data = d;
75 return res;
76 }
77
78 Y_PURE_FUNCTION
79 TStorageType Save() const {
80 return Data;
81 }
82
83 Y_PURE_FUNCTION
84 operator float() const {
85 return AsFloat();
86 }
87};
88
89Y_CONST_FUNCTION inline bool operator<(TFloat16 a, TFloat16 b) {
90 return float(a) < float(b);

Callers 8

Y_UNIT_TESTFunction · 0.85
ConvertFromZeroFunction · 0.85
FillConvertedFunction · 0.85
SortFunction · 0.85
Y_UNIT_TESTFunction · 0.85
TestDcgFunction · 0.85
TestNdcgFunction · 0.85

Calls

no outgoing calls

Tested by 5

SortFunction · 0.68
Y_UNIT_TESTFunction · 0.68
TestDcgFunction · 0.68
TestNdcgFunction · 0.68