17 explicit inline operator double() {
21 explicit inline operator int()
const {
24 inline bool operator<(
float16 other)
const {
return float() < (float)other; }
25 inline bool operator<=(
float16 other)
const {
26 return float() <= (float)other;
28 inline bool operator>(
float16 other)
const {
return float() > (float)other; }
29 inline bool operator>=(
float16 other)
const {
30 return float() >= (float)other;
32 inline bool operator==(
float16 other)
const {
33 return float() == (float)other;
35 inline bool operator!=(
float16 other)
const {
36 return float() != (float)other;
44 static uint32_t
as_uint(
const float x) {
return *(uint *)&x; }
47 static float as_float(
const uint32_t x) {
return *(
float *)&x; }
55 const uint32_t e = (x & 0x7C00) >> 10;
56 const uint32_t m = (x & 0x03FF) << 13;
60 return as_float((x & 0x8000) << 16 | (e != 0) * ((e + 112) << 23 | m) |
61 ((e == 0) & (m != 0)) *
75 const uint32_t e = (b & 0x7F800000) >> 23;
76 const uint32_t m = b & 0x007FFFFF;
79 return (b & 0x80000000) >> 16 |
80 (e > 112) * ((((e - 112) << 10) & 0x7C00) | m >> 13) |
81 ((e < 113) & (e > 101)) *
82 ((((0x007FF000 + m) >> (125 - e)) + 1) >> 1) |
87 inline float operator+(float16 one, float16 two) {
88 return (
float)one + (float)two;
90 inline float operator-(float16 one, float16 two) {
91 return (
float)one - (float)two;
93 inline float operator*(float16 one, float16 two) {
94 return (
float)one * (float)two;
96 inline float operator/(float16 one, float16 two) {
97 return (
float)one / (float)two;
99 inline float operator+(float16 one,
float two) {
return (
float)one + two; }
100 inline float operator-(float16 one,
float two) {
return (
float)one - two; }
101 inline float operator*(float16 one,
float two) {
return (
float)one * two; }
102 inline float operator/(float16 one,
float two) {
return (
float)one / two; }
103 inline float operator+(
float one, float16 two) {
return two + float(one); }
104 inline float operator-(
float one, float16 two) {
return two - float(one); }
105 inline float operator*(
float one, float16 two) {
return two * float(one); }
106 inline float operator/(
float one, float16 two) {
return two / float(one); }
112 inline float floor(float16 arg) {
return std::floor((
float)arg); }
113 inline float fabs(float16 arg) {
return std::fabs((
float)arg); }