56 operator float()
const
75 unsigned int float_value = ((hf & 0x8000) << 16) | (((hf & 0x7c00) + 0x1C000) << 13) | ((hf & 0x03FF) << 13);
76 void *ptr =
static_cast<void*
>(&float_value);
77 return *
static_cast<float*
>(ptr);
83 void *ptr =
static_cast<void*
>(&float_value);
84 unsigned int f = *
static_cast<unsigned int*
>(ptr);
85 return ((
f >> 16) & 0x8000) | ((((
f & 0x7f800000) - 0x38000000) >> 13) & 0x7c00) | ((
f >> 13) & 0x03ff);
90 unsigned int float_value = mantissa_table[offset_table[hf >> 10] + (hf & 0x3ff)] + exponent_table[hf >> 10];
91 void *ptr =
static_cast<void*
>(&float_value);
92 return *
static_cast<float*
>(ptr);
97 void *ptr =
static_cast<void*
>(&float_value);
98 unsigned int f = *
static_cast<unsigned int*
>(ptr);
99 return base_table[(
f >> 23) & 0x1ff] + ((
f & 0x007fffff) >> shift_table[(
f >> 23) & 0x1ff]);
103 unsigned short value;
105 static unsigned int mantissa_table[2048];
106 static unsigned int exponent_table[64];
107 static unsigned short offset_table[64];
109 static unsigned short base_table[512];
110 static unsigned char shift_table[512];
Definition half_float.h:37
static float half_to_float(unsigned short hf)
Definition half_float.h:88
static unsigned short float_to_half_simple(float float_value)
Only works for 'normal' half-float values.
Definition half_float.h:81
HalfFloat()
Definition half_float.h:39
float to_float() const
Definition half_float.h:61
static unsigned short float_to_half(float float_value)
Definition half_float.h:95
HalfFloat(const HalfFloat &other)=default
static float half_to_float_simple(unsigned short hf)
Only works for 'normal' half-float values.
Definition half_float.h:73
HalfFloat & from_float(float v)
Definition half_float.h:66
HalfFloat & operator=(const HalfFloat &other)=default
HalfFloat(float v)
Definition half_float.h:45