29 inline half(
const float f);
32 inline operator float()
const;
45 inline bool operator<(
const float rhs)
const;
53 inline bool operator>(
const float rhs)
const;
79 friend class std::numeric_limits<
Math::
half>;
107 return half((
float)one + (
float)two);
116 return half(one + (-two));
125 return half((
float)one * (
float)two);
134 return half((
float)one / (
float)two);
143 return half((
float)one + two);
152 return half(one + (-two));
161 return half((
float)one * two);
170 return half((
float)one / two);
179 return one + (float)two;
188 return one - (float)two;
197 return one * (float)two;
206 return one / (float)two;
265 case 1: this->
ieee.frac = 512 + (fl.
ieee.
frac >> 14);
break;
266 case 2: this->
ieee.frac = 256 + (fl.
ieee.
frac >> 15);
break;
267 case 3: this->
ieee.frac = 128 + (fl.
ieee.
frac >> 16);
break;
268 case 4: this->
ieee.frac = 64 + (fl.
ieee.
frac >> 17);
break;
269 case 5: this->
ieee.frac = 32 + (fl.
ieee.
frac >> 18);
break;
270 case 6: this->
ieee.frac = 16 + (fl.
ieee.
frac >> 19);
break;
271 case 7: this->
ieee.frac = 8 + (fl.
ieee.
frac >> 20);
break;
272 case 8: this->
ieee.frac = 4 + (fl.
ieee.
frac >> 21);
break;
273 case 9: this->
ieee.frac = 2 + (fl.
ieee.
frac >> 22);
break;
274 case 10: this->
ieee.frac = 1;
break;
285 this->
ieee.exp = exp + 15;
293inline half::operator float()
const
300 if (!this->ieee.frac)
307 const float half_denorm = (1.0f / 16384.0f);
308 float m = ((float)this->ieee.frac) / 1024.0f;
309 float s = this->ieee.sign ? -1.0f : 1.0f;
310 f.
f = s * m * half_denorm;
313 else if (this->ieee.exp == 31)
316 f.
ieee.
frac = this->ieee.frac != 0 ? 1 : 0;
320 f.
ieee.
exp = this->ieee.exp + 112;
321 f.
ieee.
frac = this->ieee.frac << 13;
341 return (
float)(*this) == rhs;
359 return (
float)(*this) != rhs;
368 return (int16_t)this->
bits < (int16_t)rhs.
bits;
377 return (
float)(*this) < rhs;
386 return !(*
this > rhs);
395 return !(*
this > rhs);
404 return (int16_t)this->
bits > (int16_t)rhs.
bits;
413 return (
float)(*this) > rhs;
422 return !(*
this < rhs);
431 return !(*
this < rhs);
440 *
this = (*this) + other;
450 *
this = (*this) - other;
460 *
this = (float)(*
this) * (float)other;
470 *
this = (float)(*
this) / (float)other;
485static_assert(
sizeof(
half) == 2);
493class numeric_limits<
Math::half>
498 static const bool is_specialized =
true;
515 static const int radix = 2;
516 static const int digits = 10;
517 static const int digits10 = 2;
518 static const bool is_signed =
true;
519 static const bool is_integer =
true;
520 static const bool is_exact =
false;
521 static const bool traps =
false;
522 static const bool is_modulo =
false;
523 static const bool is_bounded =
true;
540 static const bool has_infinity =
true;
541 static const bool has_quiet_NaN =
true;
542 static const bool has_signaling_NaN =
true;
543 static const bool is_iec559 =
false;
544 static const bool has_denorm = denorm_present;
545 static const bool tinyness_before =
false;
546 static const float_round_style round_style = round_to_nearest;
static const uint8_t MAX_EXPONENT
Definition half.h:84
half & operator-=(half other)
Definition half.h:448
uint16_t exp
Definition half.h:95
static const uint8_t MIN_EXPONENT
Definition half.h:85
uint16_t frac
Definition half.h:94
bool operator<=(const half rhs) const
Compare less equals.
Definition half.h:384
half operator-() const
Definition half.h:478
static const uint8_t MAX_EXPONENT10
Definition half.h:86
bool operator<(const half rhs) const
Compare less.
Definition half.h:366
struct Math::half::@22::@25 ieee
bool operator==(const half rhs) const
Compare equals.
Definition half.h:330
half & operator*=(half other)
Definition half.h:458
uint16_t bits
Definition half.h:91
uint16_t sign
Definition half.h:96
static const uint8_t BITS_MANTISSA
Definition half.h:80
static const uint8_t BIAS
Definition half.h:83
static const uint8_t BITS_EXPONENT
Definition half.h:81
half & operator/=(half other)
Definition half.h:468
half & operator+=(half other)
Definition half.h:438
bool operator!=(const half rhs) const
Compare not equals.
Definition half.h:348
static const uint8_t MAX_EXPONENT_VALUE
Definition half.h:82
bool operator>=(const half rhs) const
Compare greater equals.
Definition half.h:420
static const uint8_t MIN_EXPONENT10
Definition half.h:87
bool operator>(const half rhs) const
Compare greater.
Definition half.h:402
static Math::half max()
Definition half.h:507
static Math::half round_error()
Definition half.h:531
static Math::half epsilon()
Definition half.h:527
static Math::half quiet_NaN()
Definition half.h:564
static Math::half denorm_min()
Definition half.h:548
static Math::half infinity()
Definition half.h:556
static Math::half min()
Definition half.h:499
static Math::half signaling_NaN()
Definition half.h:572
Different curves.
Definition angularpfeedbackloop.h:17
half operator/(half one, half two)
Definition half.h:132
half operator-(half one, half two)
Definition half.h:114
half operator+(half one, half two)
Definition half.h:105
half operator*(half one, half two)
Definition half.h:123
unsigned int uint
Definition types.h:31
uint32_t exp
Definition half.h:74
float f
Definition half.h:70
uint32_t sign
Definition half.h:75
struct Math::half::Float::@24 ieee
uint32_t frac
Definition half.h:73