14 #include <type_traits>
18 std::numeric_limits<float>::is_iec559,
19 "Half-precision float implementation requires IEC 559 compliant format");
33 m_data = (in >> 16) & 0x8000;
34 uint8_t ex = (in >> 23) & 0xFF;
35 uint32_t ma = in & 0x007FFFFF;
37 if(ex == 255 && ma != 0) {
41 else if(ex > 127 + 15) {
44 else if(ex < 127 - 24) {
47 else if(ex < 127 - 14) {
48 m_data |= (ma | 0x00800000) >> (126 - ex);
51 m_data |= (ex - 127 + 15) << 10;
57 operator float()
const {
59 uint32_t out = (m_data & 0x8000) << 16;
60 uint8_t ex = (m_data >> 10) & 0x1F;
61 uint16_t ma = m_data & 0x03FF;
71 for(ex = 0; (ma & 0x0400) == 0; ++ex)
73 out |= (0x71 - ex) << 23;
74 out |= (ma & 0x03FF) << 13;
78 out |= (ex + 127 - 15) << 23;
82 memcpy(&outf, &out, 4);
94 template <>
struct is_floating_point<lumina::half> : true_type {};