26 #define HALF_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
28 #if defined(__INTEL_COMPILER)
29 #define HALF_ICC_VERSION __INTEL_COMPILER
31 #define HALF_ICC_VERSION __ICC
33 #define HALF_ICC_VERSION __ICL
35 #define HALF_ICC_VERSION 0
39 #if defined(__clang__)
40 #if __has_feature(cxx_static_assert) && !defined(HALF_ENABLE_CPP11_STATIC_ASSERT)
41 #define HALF_ENABLE_CPP11_STATIC_ASSERT 1
43 #if __has_feature(cxx_constexpr) && !defined(HALF_ENABLE_CPP11_CONSTEXPR)
44 #define HALF_ENABLE_CPP11_CONSTEXPR 1
46 #if __has_feature(cxx_noexcept) && !defined(HALF_ENABLE_CPP11_NOEXCEPT)
47 #define HALF_ENABLE_CPP11_NOEXCEPT 1
49 #if __has_feature(cxx_user_literals) && !defined(HALF_ENABLE_CPP11_USER_LITERALS)
50 #define HALF_ENABLE_CPP11_USER_LITERALS 1
52 #if __has_feature(cxx_thread_local) && !defined(HALF_ENABLE_CPP11_THREAD_LOCAL)
53 #define HALF_ENABLE_CPP11_THREAD_LOCAL 1
55 #if (defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L) && !defined(HALF_ENABLE_CPP11_LONG_LONG)
56 #define HALF_ENABLE_CPP11_LONG_LONG 1
58 #elif HALF_ICC_VERSION && defined(__INTEL_CXX11_MODE__)
59 #if HALF_ICC_VERSION >= 1500 && !defined(HALF_ENABLE_CPP11_THREAD_LOCAL)
60 #define HALF_ENABLE_CPP11_THREAD_LOCAL 1
62 #if HALF_ICC_VERSION >= 1500 && !defined(HALF_ENABLE_CPP11_USER_LITERALS)
63 #define HALF_ENABLE_CPP11_USER_LITERALS 1
65 #if HALF_ICC_VERSION >= 1400 && !defined(HALF_ENABLE_CPP11_CONSTEXPR)
66 #define HALF_ENABLE_CPP11_CONSTEXPR 1
68 #if HALF_ICC_VERSION >= 1400 && !defined(HALF_ENABLE_CPP11_NOEXCEPT)
69 #define HALF_ENABLE_CPP11_NOEXCEPT 1
71 #if HALF_ICC_VERSION >= 1110 && !defined(HALF_ENABLE_CPP11_STATIC_ASSERT)
72 #define HALF_ENABLE_CPP11_STATIC_ASSERT 1
74 #if HALF_ICC_VERSION >= 1110 && !defined(HALF_ENABLE_CPP11_LONG_LONG)
75 #define HALF_ENABLE_CPP11_LONG_LONG 1
77 #elif defined(__GNUC__)
78 #if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
79 #if HALF_GCC_VERSION >= 408 && !defined(HALF_ENABLE_CPP11_THREAD_LOCAL)
80 #define HALF_ENABLE_CPP11_THREAD_LOCAL 1
82 #if HALF_GCC_VERSION >= 407 && !defined(HALF_ENABLE_CPP11_USER_LITERALS)
83 #define HALF_ENABLE_CPP11_USER_LITERALS 1
85 #if HALF_GCC_VERSION >= 406 && !defined(HALF_ENABLE_CPP11_CONSTEXPR)
86 #define HALF_ENABLE_CPP11_CONSTEXPR 1
88 #if HALF_GCC_VERSION >= 406 && !defined(HALF_ENABLE_CPP11_NOEXCEPT)
89 #define HALF_ENABLE_CPP11_NOEXCEPT 1
91 #if HALF_GCC_VERSION >= 403 && !defined(HALF_ENABLE_CPP11_STATIC_ASSERT)
92 #define HALF_ENABLE_CPP11_STATIC_ASSERT 1
94 #if !defined(HALF_ENABLE_CPP11_LONG_LONG)
95 #define HALF_ENABLE_CPP11_LONG_LONG 1
98 #define HALF_TWOS_COMPLEMENT_INT 1
99 #elif defined(_MSC_VER)
100 #if _MSC_VER >= 1900 && !defined(HALF_ENABLE_CPP11_THREAD_LOCAL)
101 #define HALF_ENABLE_CPP11_THREAD_LOCAL 1
103 #if _MSC_VER >= 1900 && !defined(HALF_ENABLE_CPP11_USER_LITERALS)
104 #define HALF_ENABLE_CPP11_USER_LITERALS 1
106 #if _MSC_VER >= 1900 && !defined(HALF_ENABLE_CPP11_CONSTEXPR)
107 #define HALF_ENABLE_CPP11_CONSTEXPR 1
109 #if _MSC_VER >= 1900 && !defined(HALF_ENABLE_CPP11_NOEXCEPT)
110 #define HALF_ENABLE_CPP11_NOEXCEPT 1
112 #if _MSC_VER >= 1600 && !defined(HALF_ENABLE_CPP11_STATIC_ASSERT)
113 #define HALF_ENABLE_CPP11_STATIC_ASSERT 1
115 #if _MSC_VER >= 1310 && !defined(HALF_ENABLE_CPP11_LONG_LONG)
116 #define HALF_ENABLE_CPP11_LONG_LONG 1
118 #define HALF_TWOS_COMPLEMENT_INT 1
119 #define HALF_POP_WARNINGS 1
120 #pragma warning(push)
121 #pragma warning(disable : 4099 4127 4146)
126 #if defined(_LIBCPP_VERSION)
127 #if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103
128 #ifndef HALF_ENABLE_CPP11_TYPE_TRAITS
129 #define HALF_ENABLE_CPP11_TYPE_TRAITS 1
131 #ifndef HALF_ENABLE_CPP11_CSTDINT
132 #define HALF_ENABLE_CPP11_CSTDINT 1
134 #ifndef HALF_ENABLE_CPP11_CMATH
135 #define HALF_ENABLE_CPP11_CMATH 1
137 #ifndef HALF_ENABLE_CPP11_HASH
138 #define HALF_ENABLE_CPP11_HASH 1
140 #ifndef HALF_ENABLE_CPP11_CFENV
141 #define HALF_ENABLE_CPP11_CFENV 1
144 #elif defined(__GLIBCXX__)
145 #if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103
147 #if __GLIBCXX__ >= 20080606 && !defined(HALF_ENABLE_CPP11_TYPE_TRAITS)
148 #define HALF_ENABLE_CPP11_TYPE_TRAITS 1
150 #if __GLIBCXX__ >= 20080606 && !defined(HALF_ENABLE_CPP11_CSTDINT)
151 #define HALF_ENABLE_CPP11_CSTDINT 1
153 #if __GLIBCXX__ >= 20080606 && !defined(HALF_ENABLE_CPP11_CMATH)
154 #define HALF_ENABLE_CPP11_CMATH 1
156 #if __GLIBCXX__ >= 20080606 && !defined(HALF_ENABLE_CPP11_HASH)
157 #define HALF_ENABLE_CPP11_HASH 1
159 #if __GLIBCXX__ >= 20080606 && !defined(HALF_ENABLE_CPP11_CFENV)
160 #define HALF_ENABLE_CPP11_CFENV 1
163 #if HALF_GCC_VERSION >= 403 && !defined(HALF_ENABLE_CPP11_TYPE_TRAITS)
164 #define HALF_ENABLE_CPP11_TYPE_TRAITS 1
166 #if HALF_GCC_VERSION >= 403 && !defined(HALF_ENABLE_CPP11_CSTDINT)
167 #define HALF_ENABLE_CPP11_CSTDINT 1
169 #if HALF_GCC_VERSION >= 403 && !defined(HALF_ENABLE_CPP11_CMATH)
170 #define HALF_ENABLE_CPP11_CMATH 1
172 #if HALF_GCC_VERSION >= 403 && !defined(HALF_ENABLE_CPP11_HASH)
173 #define HALF_ENABLE_CPP11_HASH 1
175 #if HALF_GCC_VERSION >= 403 && !defined(HALF_ENABLE_CPP11_CFENV)
176 #define HALF_ENABLE_CPP11_CFENV 1
180 #elif defined(_CPPLIB_VER)
181 #if _CPPLIB_VER >= 520 && !defined(HALF_ENABLE_CPP11_TYPE_TRAITS)
182 #define HALF_ENABLE_CPP11_TYPE_TRAITS 1
184 #if _CPPLIB_VER >= 520 && !defined(HALF_ENABLE_CPP11_CSTDINT)
185 #define HALF_ENABLE_CPP11_CSTDINT 1
187 #if _CPPLIB_VER >= 520 && !defined(HALF_ENABLE_CPP11_HASH)
188 #define HALF_ENABLE_CPP11_HASH 1
190 #if _CPPLIB_VER >= 610 && !defined(HALF_ENABLE_CPP11_CMATH)
191 #define HALF_ENABLE_CPP11_CMATH 1
193 #if _CPPLIB_VER >= 610 && !defined(HALF_ENABLE_CPP11_CFENV)
194 #define HALF_ENABLE_CPP11_CFENV 1
197 #undef HALF_GCC_VERSION
198 #undef HALF_ICC_VERSION
201 #if defined(HALF_ERRHANDLING_THROW_INVALID) || defined(HALF_ERRHANDLING_THROW_DIVBYZERO) || \
202 defined(HALF_ERRHANDLING_THROW_OVERFLOW) || defined(HALF_ERRHANDLING_THROW_UNDERFLOW) || \
203 defined(HALF_ERRHANDLING_THROW_INEXACT)
204 #define HALF_ERRHANDLING_THROWS 1
208 #define HALF_ERRHANDLING \
209 (HALF_ERRHANDLING_FLAGS || HALF_ERRHANDLING_ERRNO || HALF_ERRHANDLING_FENV || HALF_ERRHANDLING_THROWS)
212 #define HALF_UNUSED_NOERR(name) name
214 #define HALF_UNUSED_NOERR(name)
218 #if HALF_ENABLE_CPP11_CONSTEXPR
219 #define HALF_CONSTEXPR constexpr
220 #define HALF_CONSTEXPR_CONST constexpr
222 #define HALF_CONSTEXPR_NOERR
224 #define HALF_CONSTEXPR_NOERR constexpr
227 #define HALF_CONSTEXPR
228 #define HALF_CONSTEXPR_CONST const
229 #define HALF_CONSTEXPR_NOERR
233 #if HALF_ENABLE_CPP11_NOEXCEPT
234 #define HALF_NOEXCEPT noexcept
235 #define HALF_NOTHROW noexcept
237 #define HALF_NOEXCEPT
238 #define HALF_NOTHROW throw()
242 #if HALF_ENABLE_CPP11_THREAD_LOCAL
243 #define HALF_THREAD_LOCAL thread_local
245 #define HALF_THREAD_LOCAL static
258 #if HALF_ENABLE_CPP11_TYPE_TRAITS
259 #include <type_traits>
261 #if HALF_ENABLE_CPP11_CSTDINT
264 #if HALF_ERRHANDLING_ERRNO
267 #if HALF_ENABLE_CPP11_CFENV
270 #if HALF_ENABLE_CPP11_HASH
271 #include <functional>
274 #ifndef HALF_ENABLE_F16C_INTRINSICS
283 #define HALF_ENABLE_F16C_INTRINSICS __F16C__
285 #if HALF_ENABLE_F16C_INTRINSICS
286 #include <immintrin.h>
289 #ifdef HALF_DOXYGEN_ONLY
296 #define HALF_ARITHMETIC_TYPE (undefined)
301 #define HALF_ERRHANDLING_FLAGS 0
308 #define HALF_ERRHANDLING_ERRNO 0
316 #define HALF_ERRHANDLING_FENV 0
322 #define HALF_ERRHANDLING_THROW_INVALID (undefined)
327 #define HALF_ERRHANDLING_THROW_DIVBYZERO (undefined)
333 #define HALF_ERRHANDLING_THROW_OVERFLOW (undefined)
339 #define HALF_ERRHANDLING_THROW_UNDERFLOW (undefined)
345 #define HALF_ERRHANDLING_THROW_INEXACT (undefined)
348 #ifndef HALF_ERRHANDLING_OVERFLOW_TO_INEXACT
352 #define HALF_ERRHANDLING_OVERFLOW_TO_INEXACT 1
355 #ifndef HALF_ERRHANDLING_UNDERFLOW_TO_INEXACT
363 #define HALF_ERRHANDLING_UNDERFLOW_TO_INEXACT 1
386 #ifndef HALF_ROUND_STYLE
387 #define HALF_ROUND_STYLE 1
395 #define HUGE_VALH std::numeric_limits<half_float::half>::infinity()
402 #define FP_FAST_FMAH 1
409 #define HLF_ROUNDS HALF_ROUND_STYLE
412 #define FP_ILOGB0 INT_MIN
415 #define FP_ILOGBNAN INT_MAX
418 #define FP_SUBNORMAL 0
427 #define FP_INFINITE 3
433 #if !HALF_ENABLE_CPP11_CFENV && !defined(FE_ALL_EXCEPT)
434 #define FE_INVALID 0x10
435 #define FE_DIVBYZERO 0x08
436 #define FE_OVERFLOW 0x04
437 #define FE_UNDERFLOW 0x02
438 #define FE_INEXACT 0x01
439 #define FE_ALL_EXCEPT (FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT)
447 #if HALF_ENABLE_CPP11_USER_LITERALS
455 half operator"" _h(
long double);
462 #if HALF_ENABLE_CPP11_TYPE_TRAITS
464 template <
bool B,
typename T,
typename F>
struct conditional : std::conditional<B, T, F> {};
467 template <
bool B>
struct bool_type : std::integral_constant<bool, B> {};
472 template <
typename T>
struct is_float : std::is_floating_point<T> {};
498 template <
typename T>
struct bits {
501 template <
typename T>
struct bits<const
T> :
bits<T> {};
502 template <
typename T>
struct bits<volatile
T> :
bits<T> {};
503 template <
typename T>
struct bits<const volatile
T> :
bits<T> {};
505 #if HALF_ENABLE_CPP11_CSTDINT
507 typedef std::uint_least16_t
uint16;
510 typedef std::uint_fast32_t
uint32;
513 typedef std::int_fast32_t
int32;
516 template <>
struct bits<float> {
517 typedef std::uint_least32_t
type;
521 template <>
struct bits<double> {
522 typedef std::uint_least64_t
type;
536 struct bits<float> :
conditional<std::numeric_limits<unsigned int>::digits >= 32, unsigned int, unsigned long> {};
538 #if HALF_ENABLE_CPP11_LONG_LONG
542 :
conditional<std::numeric_limits<unsigned long>::digits >= 64, unsigned long, unsigned long long> {};
545 template <>
struct bits<double> {
551 #ifdef HALF_ARITHMETIC_TYPE
553 typedef HALF_ARITHMETIC_TYPE internal_t;
572 #if HALF_ENABLE_CPP11_CMATH
574 #elif defined(_MSC_VER)
575 return !::_finite(
static_cast<double>(arg)) && !::_isnan(
static_cast<double>(arg));
577 return arg == std::numeric_limits<T>::infinity() || arg == -std::numeric_limits<T>::infinity();
588 #if HALF_ENABLE_CPP11_CMATH
590 #elif defined(_MSC_VER)
591 return ::_isnan(
static_cast<double>(arg)) != 0;
604 #if HALF_ENABLE_CPP11_CMATH
607 return arg <
T() || (arg ==
T() &&
T(1) / arg <
T());
617 static const int N = std::numeric_limits<uint32>::digits - 1;
618 #if HALF_TWOS_COMPLEMENT_INT
619 return static_cast<int32>(arg) >> N;
621 return -((arg >> N) & 1);
631 #if HALF_TWOS_COMPLEMENT_INT
632 return static_cast<int32>(arg) >> i;
634 return static_cast<int32>(arg) / (
static_cast<int32>(1) << i) -
635 ((arg >> (std::numeric_limits<uint32>::digits - 1)) & 1);
659 #if HALF_ERRHANDLING_FLAGS
662 #if HALF_ERRHANDLING_ERRNO
668 #if HALF_ERRHANDLING_FENV && HALF_ENABLE_CPP11_CFENV
671 #ifdef HALF_ERRHANDLING_THROW_INVALID
673 throw std::domain_error(HALF_ERRHANDLING_THROW_INVALID);
675 #ifdef HALF_ERRHANDLING_THROW_DIVBYZERO
677 throw std::domain_error(HALF_ERRHANDLING_THROW_DIVBYZERO);
679 #ifdef HALF_ERRHANDLING_THROW_OVERFLOW
681 throw std::overflow_error(HALF_ERRHANDLING_THROW_OVERFLOW);
683 #ifdef HALF_ERRHANDLING_THROW_UNDERFLOW
685 throw std::underflow_error(HALF_ERRHANDLING_THROW_UNDERFLOW);
687 #ifdef HALF_ERRHANDLING_THROW_INEXACT
689 throw std::range_error(HALF_ERRHANDLING_THROW_INEXACT);
691 #if HALF_ERRHANDLING_UNDERFLOW_TO_INEXACT
695 #if HALF_ERRHANDLING_OVERFLOW_TO_INEXACT
711 raise(
FE_INVALID, (x & 0x7FFF) > 0x7C00 || (y & 0x7FFF) > 0x7C00);
713 return (x & 0x7FFF) > 0x7C00 || (y & 0x7FFF) > 0x7C00;
736 raise(
FE_INVALID, ((x & 0x7FFF) > 0x7C00 && !(x & 0x200)) || ((y & 0x7FFF) > 0x7C00 && !(y & 0x200)));
738 return ((x & 0x7FFF) > 0x7C00) ? (x | 0x200) : (y | 0x200);
751 ((x & 0x7FFF) > 0x7C00 && !(x & 0x200)) || ((y & 0x7FFF) > 0x7C00 && !(y & 0x200)) ||
752 ((z & 0x7FFF) > 0x7C00 && !(z & 0x200)));
754 return ((x & 0x7FFF) > 0x7C00) ? (x | 0x200) : ((y & 0x7FFF) > 0x7C00) ? (y | 0x200) : (z | 0x200);
765 return (((y & 0x7FFF) > 0x7C00) && !(y & 0x200)) ?
signal(y) : x;
791 return sign | 0x7C00;
800 #if HALF_ERRHANDLING && !HALF_ERRHANDLING_UNDERFLOW_TO_INEXACT
820 return (
R == std::round_toward_infinity) ? (sign + 0x7C00 - (sign >> 15))
821 : (
R == std::round_toward_neg_infinity) ? (sign + 0x7BFF + (sign >> 15))
822 : (
R == std::round_toward_zero) ? (sign | 0x7BFF)
836 return (
R == std::round_toward_infinity) ? (sign + 1 - (sign >> 15))
837 : (
R == std::round_toward_neg_infinity) ? (sign + (sign >> 15))
851 template <std::
float_round_style R,
bool I>
855 value += (
R == std::round_to_nearest) ? (g & (s | value))
856 : (
R == std::round_toward_infinity) ? (~(value >> 15) & (g | s))
857 : (
R == std::round_toward_neg_infinity) ? ((value >> 15) & (g | s))
859 if ((value & 0x7C00) == 0x7C00)
861 else if (value & 0x7C00)
867 return (
R == std::round_to_nearest) ? (value + (g & (s | value)))
868 : (
R == std::round_toward_infinity) ? (value + (~(value >> 15) & (g | s)))
869 : (
R == std::round_toward_neg_infinity) ? (value + ((value >> 15) & (g | s)))
882 template <std::
float_round_style R,
bool E,
bool I>
unsigned int integral(
unsigned int value)
884 unsigned int abs = value & 0x7FFF;
887 return ((
R == std::round_to_nearest) ? (0x3C00 & -
static_cast<unsigned>(
abs >= (0x3800 + E)))
888 : (
R == std::round_toward_infinity) ? (0x3C00 & -(~(value >> 15) & (
abs != 0)))
889 : (
R == std::round_toward_neg_infinity) ? (0x3C00 & -
static_cast<unsigned>(value > 0x8000))
894 return (
abs > 0x7C00) ?
signal(value) : value;
895 unsigned int exp = 25 - (
abs >> 10), mask = (1 <<
exp) - 1;
897 return (((
R == std::round_to_nearest) ? ((1 << (
exp - 1)) - (~(value >>
exp) & E))
898 : (
R == std::round_toward_infinity) ? (mask & ((value >> 15) - 1))
899 : (
R == std::round_toward_neg_infinity) ? (mask & -(value >> 15))
919 template <std::
float_round_style R,
unsigned int F,
bool S,
bool N,
bool I>
924 m = (m ^ msign) - msign;
925 sign = msign & 0x8000;
928 for (; m < (static_cast<uint32>(1) << F) &&
exp; m <<= 1, --
exp)
931 return rounded<R, I>(sign + (m >> (F - 10 -
exp)), (m >> (F - 11 -
exp)) & 1,
932 s | ((m & ((
static_cast<uint32>(1) << (F - 11 -
exp)) - 1)) != 0));
933 return rounded<R, I>(sign + (
exp << 10) + (m >> (F - 10)), (m >> (F - 11)) & 1,
934 s | ((m & ((
static_cast<uint32>(1) << (F - 11)) - 1)) != 0));
947 #if HALF_ENABLE_F16C_INTRINSICS
948 return _mm_cvtsi128_si32(_mm_cvtps_ph(_mm_set_ss(value),
949 (
R == std::round_to_nearest) ? _MM_FROUND_TO_NEAREST_INT
950 : (
R == std::round_toward_zero) ? _MM_FROUND_TO_ZERO
951 : (
R == std::round_toward_infinity) ? _MM_FROUND_TO_POS_INF
952 : (
R == std::round_toward_neg_infinity) ? _MM_FROUND_TO_NEG_INF
953 : _MM_FROUND_CUR_DIRECTION));
956 std::memcpy(&fbits, &value,
sizeof(
float));
958 unsigned int sign = (fbits >> 16) & 0x8000;
960 if (fbits >= 0x7F800000)
961 return sign | 0x7C00 | ((fbits > 0x7F800000) ? (0x200 | ((fbits >> 13) & 0x3FF)) : 0);
962 if (fbits >= 0x47800000)
963 return overflow<R>(sign);
964 if (fbits >= 0x38800000)
965 return rounded<R, false>(sign | (((fbits >> 23) - 112) << 10) | ((fbits >> 13) & 0x3FF), (fbits >> 12) & 1,
966 (fbits & 0xFFF) != 0);
967 if (fbits >= 0x33000000) {
968 int i = 125 - (fbits >> 23);
969 fbits = (fbits & 0x7FFFFF) | 0x800000;
970 return rounded<R, false>(
971 sign | (fbits >> (i + 1)), (fbits >> i) & 1, (fbits & ((
static_cast<uint32>(1) << i) - 1)) != 0);
974 return underflow<R>(sign);
977 static const uint16 base_table[512] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
978 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
979 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
980 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
981 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
982 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
983 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
984 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
985 0x0000, 0x0000, 0x0000, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080, 0x0100, 0x0200,
986 0x0400, 0x0800, 0x0C00, 0x1000, 0x1400, 0x1800, 0x1C00, 0x2000, 0x2400, 0x2800, 0x2C00, 0x3000, 0x3400,
987 0x3800, 0x3C00, 0x4000, 0x4400, 0x4800, 0x4C00, 0x5000, 0x5400, 0x5800, 0x5C00, 0x6000, 0x6400, 0x6800,
988 0x6C00, 0x7000, 0x7400, 0x7800, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF,
989 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF,
990 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF,
991 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF,
992 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF,
993 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF,
994 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF,
995 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF,
996 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7BFF, 0x7C00,
997 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
998 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
999 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
1000 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
1001 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
1002 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
1003 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000,
1004 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8000, 0x8001,
1005 0x8002, 0x8004, 0x8008, 0x8010, 0x8020, 0x8040, 0x8080, 0x8100, 0x8200, 0x8400, 0x8800, 0x8C00, 0x9000,
1006 0x9400, 0x9800, 0x9C00, 0xA000, 0xA400, 0xA800, 0xAC00, 0xB000, 0xB400, 0xB800, 0xBC00, 0xC000, 0xC400,
1007 0xC800, 0xCC00, 0xD000, 0xD400, 0xD800, 0xDC00, 0xE000, 0xE400, 0xE800, 0xEC00, 0xF000, 0xF400, 0xF800,
1008 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF,
1009 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF,
1010 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF,
1011 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF,
1012 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF,
1013 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF,
1014 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF,
1015 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF,
1016 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFBFF, 0xFC00 };
1017 static const unsigned char shift_table[256] = { 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
1018 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
1019 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
1020 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
1021 25, 25, 25, 25, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
1022 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 24, 24, 24, 24, 24, 24, 24, 24,
1023 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
1024 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
1025 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
1026 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 13 };
1027 int sexp = fbits >> 23,
exp = sexp & 0xFF, i = shift_table[
exp];
1030 return rounded<R, false>(
1031 base_table[sexp] + (fbits >> i), (m >> (i - 1)) & 1, (((
static_cast<uint32>(1) << (i - 1)) - 1) & m) != 0);
1045 #if HALF_ENABLE_F16C_INTRINSICS
1046 if (
R == std::round_indeterminate)
1047 return _mm_cvtsi128_si32(_mm_cvtps_ph(_mm_cvtpd_ps(_mm_set_sd(value)), _MM_FROUND_CUR_DIRECTION));
1050 std::memcpy(&dbits, &value,
sizeof(
double));
1051 uint32 hi = dbits >> 32, lo = dbits & 0xFFFFFFFF;
1052 unsigned int sign = (hi >> 16) & 0x8000;
1054 if (hi >= 0x7FF00000)
1055 return sign | 0x7C00 | ((dbits & 0xFFFFFFFFFFFFF) ? (0x200 | ((hi >> 10) & 0x3FF)) : 0);
1056 if (hi >= 0x40F00000)
1057 return overflow<R>(sign);
1058 if (hi >= 0x3F100000)
1059 return rounded<R, false>(
1060 sign | (((hi >> 20) - 1008) << 10) | ((hi >> 10) & 0x3FF), (hi >> 9) & 1, ((hi & 0x1FF) | lo) != 0);
1061 if (hi >= 0x3E600000) {
1062 int i = 1018 - (hi >> 20);
1063 hi = (hi & 0xFFFFF) | 0x100000;
1064 return rounded<R, false>(
1065 sign | (hi >> (i + 1)), (hi >> i) & 1, ((hi & ((
static_cast<uint32>(1) << i) - 1)) | lo) != 0);
1068 return underflow<R>(sign);
1082 unsigned int hbits =
static_cast<unsigned>(
builtin_signbit(value)) << 15;
1086 return hbits | 0x7FFF;
1088 return hbits | 0x7C00;
1092 return overflow<R>(hbits);
1097 hbits |= ((
exp + 13) << 10);
1100 int m =
std::abs(
static_cast<int>(ival));
1101 return rounded<R, false>(hbits + (m >> 1), m & 1, frac !=
T());
1112 template <std::
float_round_style R,
typename T>
unsigned int float2half(
T value)
1114 return float2half_impl<R>(
1125 template <std::
float_round_style R,
typename T>
unsigned int int2half(
T value)
1127 unsigned int bits =
static_cast<unsigned>(value < 0) << 15;
1133 return overflow<R>(
bits);
1134 unsigned int m =
static_cast<unsigned int>(value),
exp = 24;
1135 for (; m < 0x400; m <<= 1, --
exp)
1137 for (; m > 0x7FF; m >>= 1, ++
exp)
1140 return (
exp > 24) ? rounded<R, false>(
bits, (value >> (
exp - 25)) & 1, (((1 << (
exp - 25)) - 1) & value) != 0)
1150 #if HALF_ENABLE_F16C_INTRINSICS
1151 return _mm_cvtss_f32(_mm_cvtph_ps(_mm_cvtsi32_si128(value)));
1155 int abs = value & 0x7FFF;
1158 fbits |= 0x38000000 <<
static_cast<unsigned>(
abs>=0x7C00);
1159 for(;
abs<0x400;
abs<<=1,fbits-=0x800000) ;
1163 static const bits<float>::type mantissa_table[2048] = { 0x00000000, 0x33800000, 0x34000000, 0x34400000,
1164 0x34800000, 0x34A00000, 0x34C00000, 0x34E00000, 0x35000000, 0x35100000, 0x35200000, 0x35300000, 0x35400000,
1165 0x35500000, 0x35600000, 0x35700000, 0x35800000, 0x35880000, 0x35900000, 0x35980000, 0x35A00000, 0x35A80000,
1166 0x35B00000, 0x35B80000, 0x35C00000, 0x35C80000, 0x35D00000, 0x35D80000, 0x35E00000, 0x35E80000, 0x35F00000,
1167 0x35F80000, 0x36000000, 0x36040000, 0x36080000, 0x360C0000, 0x36100000, 0x36140000, 0x36180000, 0x361C0000,
1168 0x36200000, 0x36240000, 0x36280000, 0x362C0000, 0x36300000, 0x36340000, 0x36380000, 0x363C0000, 0x36400000,
1169 0x36440000, 0x36480000, 0x364C0000, 0x36500000, 0x36540000, 0x36580000, 0x365C0000, 0x36600000, 0x36640000,
1170 0x36680000, 0x366C0000, 0x36700000, 0x36740000, 0x36780000, 0x367C0000, 0x36800000, 0x36820000, 0x36840000,
1171 0x36860000, 0x36880000, 0x368A0000, 0x368C0000, 0x368E0000, 0x36900000, 0x36920000, 0x36940000, 0x36960000,
1172 0x36980000, 0x369A0000, 0x369C0000, 0x369E0000, 0x36A00000, 0x36A20000, 0x36A40000, 0x36A60000, 0x36A80000,
1173 0x36AA0000, 0x36AC0000, 0x36AE0000, 0x36B00000, 0x36B20000, 0x36B40000, 0x36B60000, 0x36B80000, 0x36BA0000,
1174 0x36BC0000, 0x36BE0000, 0x36C00000, 0x36C20000, 0x36C40000, 0x36C60000, 0x36C80000, 0x36CA0000, 0x36CC0000,
1175 0x36CE0000, 0x36D00000, 0x36D20000, 0x36D40000, 0x36D60000, 0x36D80000, 0x36DA0000, 0x36DC0000, 0x36DE0000,
1176 0x36E00000, 0x36E20000, 0x36E40000, 0x36E60000, 0x36E80000, 0x36EA0000, 0x36EC0000, 0x36EE0000, 0x36F00000,
1177 0x36F20000, 0x36F40000, 0x36F60000, 0x36F80000, 0x36FA0000, 0x36FC0000, 0x36FE0000, 0x37000000, 0x37010000,
1178 0x37020000, 0x37030000, 0x37040000, 0x37050000, 0x37060000, 0x37070000, 0x37080000, 0x37090000, 0x370A0000,
1179 0x370B0000, 0x370C0000, 0x370D0000, 0x370E0000, 0x370F0000, 0x37100000, 0x37110000, 0x37120000, 0x37130000,
1180 0x37140000, 0x37150000, 0x37160000, 0x37170000, 0x37180000, 0x37190000, 0x371A0000, 0x371B0000, 0x371C0000,
1181 0x371D0000, 0x371E0000, 0x371F0000, 0x37200000, 0x37210000, 0x37220000, 0x37230000, 0x37240000, 0x37250000,
1182 0x37260000, 0x37270000, 0x37280000, 0x37290000, 0x372A0000, 0x372B0000, 0x372C0000, 0x372D0000, 0x372E0000,
1183 0x372F0000, 0x37300000, 0x37310000, 0x37320000, 0x37330000, 0x37340000, 0x37350000, 0x37360000, 0x37370000,
1184 0x37380000, 0x37390000, 0x373A0000, 0x373B0000, 0x373C0000, 0x373D0000, 0x373E0000, 0x373F0000, 0x37400000,
1185 0x37410000, 0x37420000, 0x37430000, 0x37440000, 0x37450000, 0x37460000, 0x37470000, 0x37480000, 0x37490000,
1186 0x374A0000, 0x374B0000, 0x374C0000, 0x374D0000, 0x374E0000, 0x374F0000, 0x37500000, 0x37510000, 0x37520000,
1187 0x37530000, 0x37540000, 0x37550000, 0x37560000, 0x37570000, 0x37580000, 0x37590000, 0x375A0000, 0x375B0000,
1188 0x375C0000, 0x375D0000, 0x375E0000, 0x375F0000, 0x37600000, 0x37610000, 0x37620000, 0x37630000, 0x37640000,
1189 0x37650000, 0x37660000, 0x37670000, 0x37680000, 0x37690000, 0x376A0000, 0x376B0000, 0x376C0000, 0x376D0000,
1190 0x376E0000, 0x376F0000, 0x37700000, 0x37710000, 0x37720000, 0x37730000, 0x37740000, 0x37750000, 0x37760000,
1191 0x37770000, 0x37780000, 0x37790000, 0x377A0000, 0x377B0000, 0x377C0000, 0x377D0000, 0x377E0000, 0x377F0000,
1192 0x37800000, 0x37808000, 0x37810000, 0x37818000, 0x37820000, 0x37828000, 0x37830000, 0x37838000, 0x37840000,
1193 0x37848000, 0x37850000, 0x37858000, 0x37860000, 0x37868000, 0x37870000, 0x37878000, 0x37880000, 0x37888000,
1194 0x37890000, 0x37898000, 0x378A0000, 0x378A8000, 0x378B0000, 0x378B8000, 0x378C0000, 0x378C8000, 0x378D0000,
1195 0x378D8000, 0x378E0000, 0x378E8000, 0x378F0000, 0x378F8000, 0x37900000, 0x37908000, 0x37910000, 0x37918000,
1196 0x37920000, 0x37928000, 0x37930000, 0x37938000, 0x37940000, 0x37948000, 0x37950000, 0x37958000, 0x37960000,
1197 0x37968000, 0x37970000, 0x37978000, 0x37980000, 0x37988000, 0x37990000, 0x37998000, 0x379A0000, 0x379A8000,
1198 0x379B0000, 0x379B8000, 0x379C0000, 0x379C8000, 0x379D0000, 0x379D8000, 0x379E0000, 0x379E8000, 0x379F0000,
1199 0x379F8000, 0x37A00000, 0x37A08000, 0x37A10000, 0x37A18000, 0x37A20000, 0x37A28000, 0x37A30000, 0x37A38000,
1200 0x37A40000, 0x37A48000, 0x37A50000, 0x37A58000, 0x37A60000, 0x37A68000, 0x37A70000, 0x37A78000, 0x37A80000,
1201 0x37A88000, 0x37A90000, 0x37A98000, 0x37AA0000, 0x37AA8000, 0x37AB0000, 0x37AB8000, 0x37AC0000, 0x37AC8000,
1202 0x37AD0000, 0x37AD8000, 0x37AE0000, 0x37AE8000, 0x37AF0000, 0x37AF8000, 0x37B00000, 0x37B08000, 0x37B10000,
1203 0x37B18000, 0x37B20000, 0x37B28000, 0x37B30000, 0x37B38000, 0x37B40000, 0x37B48000, 0x37B50000, 0x37B58000,
1204 0x37B60000, 0x37B68000, 0x37B70000, 0x37B78000, 0x37B80000, 0x37B88000, 0x37B90000, 0x37B98000, 0x37BA0000,
1205 0x37BA8000, 0x37BB0000, 0x37BB8000, 0x37BC0000, 0x37BC8000, 0x37BD0000, 0x37BD8000, 0x37BE0000, 0x37BE8000,
1206 0x37BF0000, 0x37BF8000, 0x37C00000, 0x37C08000, 0x37C10000, 0x37C18000, 0x37C20000, 0x37C28000, 0x37C30000,
1207 0x37C38000, 0x37C40000, 0x37C48000, 0x37C50000, 0x37C58000, 0x37C60000, 0x37C68000, 0x37C70000, 0x37C78000,
1208 0x37C80000, 0x37C88000, 0x37C90000, 0x37C98000, 0x37CA0000, 0x37CA8000, 0x37CB0000, 0x37CB8000, 0x37CC0000,
1209 0x37CC8000, 0x37CD0000, 0x37CD8000, 0x37CE0000, 0x37CE8000, 0x37CF0000, 0x37CF8000, 0x37D00000, 0x37D08000,
1210 0x37D10000, 0x37D18000, 0x37D20000, 0x37D28000, 0x37D30000, 0x37D38000, 0x37D40000, 0x37D48000, 0x37D50000,
1211 0x37D58000, 0x37D60000, 0x37D68000, 0x37D70000, 0x37D78000, 0x37D80000, 0x37D88000, 0x37D90000, 0x37D98000,
1212 0x37DA0000, 0x37DA8000, 0x37DB0000, 0x37DB8000, 0x37DC0000, 0x37DC8000, 0x37DD0000, 0x37DD8000, 0x37DE0000,
1213 0x37DE8000, 0x37DF0000, 0x37DF8000, 0x37E00000, 0x37E08000, 0x37E10000, 0x37E18000, 0x37E20000, 0x37E28000,
1214 0x37E30000, 0x37E38000, 0x37E40000, 0x37E48000, 0x37E50000, 0x37E58000, 0x37E60000, 0x37E68000, 0x37E70000,
1215 0x37E78000, 0x37E80000, 0x37E88000, 0x37E90000, 0x37E98000, 0x37EA0000, 0x37EA8000, 0x37EB0000, 0x37EB8000,
1216 0x37EC0000, 0x37EC8000, 0x37ED0000, 0x37ED8000, 0x37EE0000, 0x37EE8000, 0x37EF0000, 0x37EF8000, 0x37F00000,
1217 0x37F08000, 0x37F10000, 0x37F18000, 0x37F20000, 0x37F28000, 0x37F30000, 0x37F38000, 0x37F40000, 0x37F48000,
1218 0x37F50000, 0x37F58000, 0x37F60000, 0x37F68000, 0x37F70000, 0x37F78000, 0x37F80000, 0x37F88000, 0x37F90000,
1219 0x37F98000, 0x37FA0000, 0x37FA8000, 0x37FB0000, 0x37FB8000, 0x37FC0000, 0x37FC8000, 0x37FD0000, 0x37FD8000,
1220 0x37FE0000, 0x37FE8000, 0x37FF0000, 0x37FF8000, 0x38000000, 0x38004000, 0x38008000, 0x3800C000, 0x38010000,
1221 0x38014000, 0x38018000, 0x3801C000, 0x38020000, 0x38024000, 0x38028000, 0x3802C000, 0x38030000, 0x38034000,
1222 0x38038000, 0x3803C000, 0x38040000, 0x38044000, 0x38048000, 0x3804C000, 0x38050000, 0x38054000, 0x38058000,
1223 0x3805C000, 0x38060000, 0x38064000, 0x38068000, 0x3806C000, 0x38070000, 0x38074000, 0x38078000, 0x3807C000,
1224 0x38080000, 0x38084000, 0x38088000, 0x3808C000, 0x38090000, 0x38094000, 0x38098000, 0x3809C000, 0x380A0000,
1225 0x380A4000, 0x380A8000, 0x380AC000, 0x380B0000, 0x380B4000, 0x380B8000, 0x380BC000, 0x380C0000, 0x380C4000,
1226 0x380C8000, 0x380CC000, 0x380D0000, 0x380D4000, 0x380D8000, 0x380DC000, 0x380E0000, 0x380E4000, 0x380E8000,
1227 0x380EC000, 0x380F0000, 0x380F4000, 0x380F8000, 0x380FC000, 0x38100000, 0x38104000, 0x38108000, 0x3810C000,
1228 0x38110000, 0x38114000, 0x38118000, 0x3811C000, 0x38120000, 0x38124000, 0x38128000, 0x3812C000, 0x38130000,
1229 0x38134000, 0x38138000, 0x3813C000, 0x38140000, 0x38144000, 0x38148000, 0x3814C000, 0x38150000, 0x38154000,
1230 0x38158000, 0x3815C000, 0x38160000, 0x38164000, 0x38168000, 0x3816C000, 0x38170000, 0x38174000, 0x38178000,
1231 0x3817C000, 0x38180000, 0x38184000, 0x38188000, 0x3818C000, 0x38190000, 0x38194000, 0x38198000, 0x3819C000,
1232 0x381A0000, 0x381A4000, 0x381A8000, 0x381AC000, 0x381B0000, 0x381B4000, 0x381B8000, 0x381BC000, 0x381C0000,
1233 0x381C4000, 0x381C8000, 0x381CC000, 0x381D0000, 0x381D4000, 0x381D8000, 0x381DC000, 0x381E0000, 0x381E4000,
1234 0x381E8000, 0x381EC000, 0x381F0000, 0x381F4000, 0x381F8000, 0x381FC000, 0x38200000, 0x38204000, 0x38208000,
1235 0x3820C000, 0x38210000, 0x38214000, 0x38218000, 0x3821C000, 0x38220000, 0x38224000, 0x38228000, 0x3822C000,
1236 0x38230000, 0x38234000, 0x38238000, 0x3823C000, 0x38240000, 0x38244000, 0x38248000, 0x3824C000, 0x38250000,
1237 0x38254000, 0x38258000, 0x3825C000, 0x38260000, 0x38264000, 0x38268000, 0x3826C000, 0x38270000, 0x38274000,
1238 0x38278000, 0x3827C000, 0x38280000, 0x38284000, 0x38288000, 0x3828C000, 0x38290000, 0x38294000, 0x38298000,
1239 0x3829C000, 0x382A0000, 0x382A4000, 0x382A8000, 0x382AC000, 0x382B0000, 0x382B4000, 0x382B8000, 0x382BC000,
1240 0x382C0000, 0x382C4000, 0x382C8000, 0x382CC000, 0x382D0000, 0x382D4000, 0x382D8000, 0x382DC000, 0x382E0000,
1241 0x382E4000, 0x382E8000, 0x382EC000, 0x382F0000, 0x382F4000, 0x382F8000, 0x382FC000, 0x38300000, 0x38304000,
1242 0x38308000, 0x3830C000, 0x38310000, 0x38314000, 0x38318000, 0x3831C000, 0x38320000, 0x38324000, 0x38328000,
1243 0x3832C000, 0x38330000, 0x38334000, 0x38338000, 0x3833C000, 0x38340000, 0x38344000, 0x38348000, 0x3834C000,
1244 0x38350000, 0x38354000, 0x38358000, 0x3835C000, 0x38360000, 0x38364000, 0x38368000, 0x3836C000, 0x38370000,
1245 0x38374000, 0x38378000, 0x3837C000, 0x38380000, 0x38384000, 0x38388000, 0x3838C000, 0x38390000, 0x38394000,
1246 0x38398000, 0x3839C000, 0x383A0000, 0x383A4000, 0x383A8000, 0x383AC000, 0x383B0000, 0x383B4000, 0x383B8000,
1247 0x383BC000, 0x383C0000, 0x383C4000, 0x383C8000, 0x383CC000, 0x383D0000, 0x383D4000, 0x383D8000, 0x383DC000,
1248 0x383E0000, 0x383E4000, 0x383E8000, 0x383EC000, 0x383F0000, 0x383F4000, 0x383F8000, 0x383FC000, 0x38400000,
1249 0x38404000, 0x38408000, 0x3840C000, 0x38410000, 0x38414000, 0x38418000, 0x3841C000, 0x38420000, 0x38424000,
1250 0x38428000, 0x3842C000, 0x38430000, 0x38434000, 0x38438000, 0x3843C000, 0x38440000, 0x38444000, 0x38448000,
1251 0x3844C000, 0x38450000, 0x38454000, 0x38458000, 0x3845C000, 0x38460000, 0x38464000, 0x38468000, 0x3846C000,
1252 0x38470000, 0x38474000, 0x38478000, 0x3847C000, 0x38480000, 0x38484000, 0x38488000, 0x3848C000, 0x38490000,
1253 0x38494000, 0x38498000, 0x3849C000, 0x384A0000, 0x384A4000, 0x384A8000, 0x384AC000, 0x384B0000, 0x384B4000,
1254 0x384B8000, 0x384BC000, 0x384C0000, 0x384C4000, 0x384C8000, 0x384CC000, 0x384D0000, 0x384D4000, 0x384D8000,
1255 0x384DC000, 0x384E0000, 0x384E4000, 0x384E8000, 0x384EC000, 0x384F0000, 0x384F4000, 0x384F8000, 0x384FC000,
1256 0x38500000, 0x38504000, 0x38508000, 0x3850C000, 0x38510000, 0x38514000, 0x38518000, 0x3851C000, 0x38520000,
1257 0x38524000, 0x38528000, 0x3852C000, 0x38530000, 0x38534000, 0x38538000, 0x3853C000, 0x38540000, 0x38544000,
1258 0x38548000, 0x3854C000, 0x38550000, 0x38554000, 0x38558000, 0x3855C000, 0x38560000, 0x38564000, 0x38568000,
1259 0x3856C000, 0x38570000, 0x38574000, 0x38578000, 0x3857C000, 0x38580000, 0x38584000, 0x38588000, 0x3858C000,
1260 0x38590000, 0x38594000, 0x38598000, 0x3859C000, 0x385A0000, 0x385A4000, 0x385A8000, 0x385AC000, 0x385B0000,
1261 0x385B4000, 0x385B8000, 0x385BC000, 0x385C0000, 0x385C4000, 0x385C8000, 0x385CC000, 0x385D0000, 0x385D4000,
1262 0x385D8000, 0x385DC000, 0x385E0000, 0x385E4000, 0x385E8000, 0x385EC000, 0x385F0000, 0x385F4000, 0x385F8000,
1263 0x385FC000, 0x38600000, 0x38604000, 0x38608000, 0x3860C000, 0x38610000, 0x38614000, 0x38618000, 0x3861C000,
1264 0x38620000, 0x38624000, 0x38628000, 0x3862C000, 0x38630000, 0x38634000, 0x38638000, 0x3863C000, 0x38640000,
1265 0x38644000, 0x38648000, 0x3864C000, 0x38650000, 0x38654000, 0x38658000, 0x3865C000, 0x38660000, 0x38664000,
1266 0x38668000, 0x3866C000, 0x38670000, 0x38674000, 0x38678000, 0x3867C000, 0x38680000, 0x38684000, 0x38688000,
1267 0x3868C000, 0x38690000, 0x38694000, 0x38698000, 0x3869C000, 0x386A0000, 0x386A4000, 0x386A8000, 0x386AC000,
1268 0x386B0000, 0x386B4000, 0x386B8000, 0x386BC000, 0x386C0000, 0x386C4000, 0x386C8000, 0x386CC000, 0x386D0000,
1269 0x386D4000, 0x386D8000, 0x386DC000, 0x386E0000, 0x386E4000, 0x386E8000, 0x386EC000, 0x386F0000, 0x386F4000,
1270 0x386F8000, 0x386FC000, 0x38700000, 0x38704000, 0x38708000, 0x3870C000, 0x38710000, 0x38714000, 0x38718000,
1271 0x3871C000, 0x38720000, 0x38724000, 0x38728000, 0x3872C000, 0x38730000, 0x38734000, 0x38738000, 0x3873C000,
1272 0x38740000, 0x38744000, 0x38748000, 0x3874C000, 0x38750000, 0x38754000, 0x38758000, 0x3875C000, 0x38760000,
1273 0x38764000, 0x38768000, 0x3876C000, 0x38770000, 0x38774000, 0x38778000, 0x3877C000, 0x38780000, 0x38784000,
1274 0x38788000, 0x3878C000, 0x38790000, 0x38794000, 0x38798000, 0x3879C000, 0x387A0000, 0x387A4000, 0x387A8000,
1275 0x387AC000, 0x387B0000, 0x387B4000, 0x387B8000, 0x387BC000, 0x387C0000, 0x387C4000, 0x387C8000, 0x387CC000,
1276 0x387D0000, 0x387D4000, 0x387D8000, 0x387DC000, 0x387E0000, 0x387E4000, 0x387E8000, 0x387EC000, 0x387F0000,
1277 0x387F4000, 0x387F8000, 0x387FC000, 0x38000000, 0x38002000, 0x38004000, 0x38006000, 0x38008000, 0x3800A000,
1278 0x3800C000, 0x3800E000, 0x38010000, 0x38012000, 0x38014000, 0x38016000, 0x38018000, 0x3801A000, 0x3801C000,
1279 0x3801E000, 0x38020000, 0x38022000, 0x38024000, 0x38026000, 0x38028000, 0x3802A000, 0x3802C000, 0x3802E000,
1280 0x38030000, 0x38032000, 0x38034000, 0x38036000, 0x38038000, 0x3803A000, 0x3803C000, 0x3803E000, 0x38040000,
1281 0x38042000, 0x38044000, 0x38046000, 0x38048000, 0x3804A000, 0x3804C000, 0x3804E000, 0x38050000, 0x38052000,
1282 0x38054000, 0x38056000, 0x38058000, 0x3805A000, 0x3805C000, 0x3805E000, 0x38060000, 0x38062000, 0x38064000,
1283 0x38066000, 0x38068000, 0x3806A000, 0x3806C000, 0x3806E000, 0x38070000, 0x38072000, 0x38074000, 0x38076000,
1284 0x38078000, 0x3807A000, 0x3807C000, 0x3807E000, 0x38080000, 0x38082000, 0x38084000, 0x38086000, 0x38088000,
1285 0x3808A000, 0x3808C000, 0x3808E000, 0x38090000, 0x38092000, 0x38094000, 0x38096000, 0x38098000, 0x3809A000,
1286 0x3809C000, 0x3809E000, 0x380A0000, 0x380A2000, 0x380A4000, 0x380A6000, 0x380A8000, 0x380AA000, 0x380AC000,
1287 0x380AE000, 0x380B0000, 0x380B2000, 0x380B4000, 0x380B6000, 0x380B8000, 0x380BA000, 0x380BC000, 0x380BE000,
1288 0x380C0000, 0x380C2000, 0x380C4000, 0x380C6000, 0x380C8000, 0x380CA000, 0x380CC000, 0x380CE000, 0x380D0000,
1289 0x380D2000, 0x380D4000, 0x380D6000, 0x380D8000, 0x380DA000, 0x380DC000, 0x380DE000, 0x380E0000, 0x380E2000,
1290 0x380E4000, 0x380E6000, 0x380E8000, 0x380EA000, 0x380EC000, 0x380EE000, 0x380F0000, 0x380F2000, 0x380F4000,
1291 0x380F6000, 0x380F8000, 0x380FA000, 0x380FC000, 0x380FE000, 0x38100000, 0x38102000, 0x38104000, 0x38106000,
1292 0x38108000, 0x3810A000, 0x3810C000, 0x3810E000, 0x38110000, 0x38112000, 0x38114000, 0x38116000, 0x38118000,
1293 0x3811A000, 0x3811C000, 0x3811E000, 0x38120000, 0x38122000, 0x38124000, 0x38126000, 0x38128000, 0x3812A000,
1294 0x3812C000, 0x3812E000, 0x38130000, 0x38132000, 0x38134000, 0x38136000, 0x38138000, 0x3813A000, 0x3813C000,
1295 0x3813E000, 0x38140000, 0x38142000, 0x38144000, 0x38146000, 0x38148000, 0x3814A000, 0x3814C000, 0x3814E000,
1296 0x38150000, 0x38152000, 0x38154000, 0x38156000, 0x38158000, 0x3815A000, 0x3815C000, 0x3815E000, 0x38160000,
1297 0x38162000, 0x38164000, 0x38166000, 0x38168000, 0x3816A000, 0x3816C000, 0x3816E000, 0x38170000, 0x38172000,
1298 0x38174000, 0x38176000, 0x38178000, 0x3817A000, 0x3817C000, 0x3817E000, 0x38180000, 0x38182000, 0x38184000,
1299 0x38186000, 0x38188000, 0x3818A000, 0x3818C000, 0x3818E000, 0x38190000, 0x38192000, 0x38194000, 0x38196000,
1300 0x38198000, 0x3819A000, 0x3819C000, 0x3819E000, 0x381A0000, 0x381A2000, 0x381A4000, 0x381A6000, 0x381A8000,
1301 0x381AA000, 0x381AC000, 0x381AE000, 0x381B0000, 0x381B2000, 0x381B4000, 0x381B6000, 0x381B8000, 0x381BA000,
1302 0x381BC000, 0x381BE000, 0x381C0000, 0x381C2000, 0x381C4000, 0x381C6000, 0x381C8000, 0x381CA000, 0x381CC000,
1303 0x381CE000, 0x381D0000, 0x381D2000, 0x381D4000, 0x381D6000, 0x381D8000, 0x381DA000, 0x381DC000, 0x381DE000,
1304 0x381E0000, 0x381E2000, 0x381E4000, 0x381E6000, 0x381E8000, 0x381EA000, 0x381EC000, 0x381EE000, 0x381F0000,
1305 0x381F2000, 0x381F4000, 0x381F6000, 0x381F8000, 0x381FA000, 0x381FC000, 0x381FE000, 0x38200000, 0x38202000,
1306 0x38204000, 0x38206000, 0x38208000, 0x3820A000, 0x3820C000, 0x3820E000, 0x38210000, 0x38212000, 0x38214000,
1307 0x38216000, 0x38218000, 0x3821A000, 0x3821C000, 0x3821E000, 0x38220000, 0x38222000, 0x38224000, 0x38226000,
1308 0x38228000, 0x3822A000, 0x3822C000, 0x3822E000, 0x38230000, 0x38232000, 0x38234000, 0x38236000, 0x38238000,
1309 0x3823A000, 0x3823C000, 0x3823E000, 0x38240000, 0x38242000, 0x38244000, 0x38246000, 0x38248000, 0x3824A000,
1310 0x3824C000, 0x3824E000, 0x38250000, 0x38252000, 0x38254000, 0x38256000, 0x38258000, 0x3825A000, 0x3825C000,
1311 0x3825E000, 0x38260000, 0x38262000, 0x38264000, 0x38266000, 0x38268000, 0x3826A000, 0x3826C000, 0x3826E000,
1312 0x38270000, 0x38272000, 0x38274000, 0x38276000, 0x38278000, 0x3827A000, 0x3827C000, 0x3827E000, 0x38280000,
1313 0x38282000, 0x38284000, 0x38286000, 0x38288000, 0x3828A000, 0x3828C000, 0x3828E000, 0x38290000, 0x38292000,
1314 0x38294000, 0x38296000, 0x38298000, 0x3829A000, 0x3829C000, 0x3829E000, 0x382A0000, 0x382A2000, 0x382A4000,
1315 0x382A6000, 0x382A8000, 0x382AA000, 0x382AC000, 0x382AE000, 0x382B0000, 0x382B2000, 0x382B4000, 0x382B6000,
1316 0x382B8000, 0x382BA000, 0x382BC000, 0x382BE000, 0x382C0000, 0x382C2000, 0x382C4000, 0x382C6000, 0x382C8000,
1317 0x382CA000, 0x382CC000, 0x382CE000, 0x382D0000, 0x382D2000, 0x382D4000, 0x382D6000, 0x382D8000, 0x382DA000,
1318 0x382DC000, 0x382DE000, 0x382E0000, 0x382E2000, 0x382E4000, 0x382E6000, 0x382E8000, 0x382EA000, 0x382EC000,
1319 0x382EE000, 0x382F0000, 0x382F2000, 0x382F4000, 0x382F6000, 0x382F8000, 0x382FA000, 0x382FC000, 0x382FE000,
1320 0x38300000, 0x38302000, 0x38304000, 0x38306000, 0x38308000, 0x3830A000, 0x3830C000, 0x3830E000, 0x38310000,
1321 0x38312000, 0x38314000, 0x38316000, 0x38318000, 0x3831A000, 0x3831C000, 0x3831E000, 0x38320000, 0x38322000,
1322 0x38324000, 0x38326000, 0x38328000, 0x3832A000, 0x3832C000, 0x3832E000, 0x38330000, 0x38332000, 0x38334000,
1323 0x38336000, 0x38338000, 0x3833A000, 0x3833C000, 0x3833E000, 0x38340000, 0x38342000, 0x38344000, 0x38346000,
1324 0x38348000, 0x3834A000, 0x3834C000, 0x3834E000, 0x38350000, 0x38352000, 0x38354000, 0x38356000, 0x38358000,
1325 0x3835A000, 0x3835C000, 0x3835E000, 0x38360000, 0x38362000, 0x38364000, 0x38366000, 0x38368000, 0x3836A000,
1326 0x3836C000, 0x3836E000, 0x38370000, 0x38372000, 0x38374000, 0x38376000, 0x38378000, 0x3837A000, 0x3837C000,
1327 0x3837E000, 0x38380000, 0x38382000, 0x38384000, 0x38386000, 0x38388000, 0x3838A000, 0x3838C000, 0x3838E000,
1328 0x38390000, 0x38392000, 0x38394000, 0x38396000, 0x38398000, 0x3839A000, 0x3839C000, 0x3839E000, 0x383A0000,
1329 0x383A2000, 0x383A4000, 0x383A6000, 0x383A8000, 0x383AA000, 0x383AC000, 0x383AE000, 0x383B0000, 0x383B2000,
1330 0x383B4000, 0x383B6000, 0x383B8000, 0x383BA000, 0x383BC000, 0x383BE000, 0x383C0000, 0x383C2000, 0x383C4000,
1331 0x383C6000, 0x383C8000, 0x383CA000, 0x383CC000, 0x383CE000, 0x383D0000, 0x383D2000, 0x383D4000, 0x383D6000,
1332 0x383D8000, 0x383DA000, 0x383DC000, 0x383DE000, 0x383E0000, 0x383E2000, 0x383E4000, 0x383E6000, 0x383E8000,
1333 0x383EA000, 0x383EC000, 0x383EE000, 0x383F0000, 0x383F2000, 0x383F4000, 0x383F6000, 0x383F8000, 0x383FA000,
1334 0x383FC000, 0x383FE000, 0x38400000, 0x38402000, 0x38404000, 0x38406000, 0x38408000, 0x3840A000, 0x3840C000,
1335 0x3840E000, 0x38410000, 0x38412000, 0x38414000, 0x38416000, 0x38418000, 0x3841A000, 0x3841C000, 0x3841E000,
1336 0x38420000, 0x38422000, 0x38424000, 0x38426000, 0x38428000, 0x3842A000, 0x3842C000, 0x3842E000, 0x38430000,
1337 0x38432000, 0x38434000, 0x38436000, 0x38438000, 0x3843A000, 0x3843C000, 0x3843E000, 0x38440000, 0x38442000,
1338 0x38444000, 0x38446000, 0x38448000, 0x3844A000, 0x3844C000, 0x3844E000, 0x38450000, 0x38452000, 0x38454000,
1339 0x38456000, 0x38458000, 0x3845A000, 0x3845C000, 0x3845E000, 0x38460000, 0x38462000, 0x38464000, 0x38466000,
1340 0x38468000, 0x3846A000, 0x3846C000, 0x3846E000, 0x38470000, 0x38472000, 0x38474000, 0x38476000, 0x38478000,
1341 0x3847A000, 0x3847C000, 0x3847E000, 0x38480000, 0x38482000, 0x38484000, 0x38486000, 0x38488000, 0x3848A000,
1342 0x3848C000, 0x3848E000, 0x38490000, 0x38492000, 0x38494000, 0x38496000, 0x38498000, 0x3849A000, 0x3849C000,
1343 0x3849E000, 0x384A0000, 0x384A2000, 0x384A4000, 0x384A6000, 0x384A8000, 0x384AA000, 0x384AC000, 0x384AE000,
1344 0x384B0000, 0x384B2000, 0x384B4000, 0x384B6000, 0x384B8000, 0x384BA000, 0x384BC000, 0x384BE000, 0x384C0000,
1345 0x384C2000, 0x384C4000, 0x384C6000, 0x384C8000, 0x384CA000, 0x384CC000, 0x384CE000, 0x384D0000, 0x384D2000,
1346 0x384D4000, 0x384D6000, 0x384D8000, 0x384DA000, 0x384DC000, 0x384DE000, 0x384E0000, 0x384E2000, 0x384E4000,
1347 0x384E6000, 0x384E8000, 0x384EA000, 0x384EC000, 0x384EE000, 0x384F0000, 0x384F2000, 0x384F4000, 0x384F6000,
1348 0x384F8000, 0x384FA000, 0x384FC000, 0x384FE000, 0x38500000, 0x38502000, 0x38504000, 0x38506000, 0x38508000,
1349 0x3850A000, 0x3850C000, 0x3850E000, 0x38510000, 0x38512000, 0x38514000, 0x38516000, 0x38518000, 0x3851A000,
1350 0x3851C000, 0x3851E000, 0x38520000, 0x38522000, 0x38524000, 0x38526000, 0x38528000, 0x3852A000, 0x3852C000,
1351 0x3852E000, 0x38530000, 0x38532000, 0x38534000, 0x38536000, 0x38538000, 0x3853A000, 0x3853C000, 0x3853E000,
1352 0x38540000, 0x38542000, 0x38544000, 0x38546000, 0x38548000, 0x3854A000, 0x3854C000, 0x3854E000, 0x38550000,
1353 0x38552000, 0x38554000, 0x38556000, 0x38558000, 0x3855A000, 0x3855C000, 0x3855E000, 0x38560000, 0x38562000,
1354 0x38564000, 0x38566000, 0x38568000, 0x3856A000, 0x3856C000, 0x3856E000, 0x38570000, 0x38572000, 0x38574000,
1355 0x38576000, 0x38578000, 0x3857A000, 0x3857C000, 0x3857E000, 0x38580000, 0x38582000, 0x38584000, 0x38586000,
1356 0x38588000, 0x3858A000, 0x3858C000, 0x3858E000, 0x38590000, 0x38592000, 0x38594000, 0x38596000, 0x38598000,
1357 0x3859A000, 0x3859C000, 0x3859E000, 0x385A0000, 0x385A2000, 0x385A4000, 0x385A6000, 0x385A8000, 0x385AA000,
1358 0x385AC000, 0x385AE000, 0x385B0000, 0x385B2000, 0x385B4000, 0x385B6000, 0x385B8000, 0x385BA000, 0x385BC000,
1359 0x385BE000, 0x385C0000, 0x385C2000, 0x385C4000, 0x385C6000, 0x385C8000, 0x385CA000, 0x385CC000, 0x385CE000,
1360 0x385D0000, 0x385D2000, 0x385D4000, 0x385D6000, 0x385D8000, 0x385DA000, 0x385DC000, 0x385DE000, 0x385E0000,
1361 0x385E2000, 0x385E4000, 0x385E6000, 0x385E8000, 0x385EA000, 0x385EC000, 0x385EE000, 0x385F0000, 0x385F2000,
1362 0x385F4000, 0x385F6000, 0x385F8000, 0x385FA000, 0x385FC000, 0x385FE000, 0x38600000, 0x38602000, 0x38604000,
1363 0x38606000, 0x38608000, 0x3860A000, 0x3860C000, 0x3860E000, 0x38610000, 0x38612000, 0x38614000, 0x38616000,
1364 0x38618000, 0x3861A000, 0x3861C000, 0x3861E000, 0x38620000, 0x38622000, 0x38624000, 0x38626000, 0x38628000,
1365 0x3862A000, 0x3862C000, 0x3862E000, 0x38630000, 0x38632000, 0x38634000, 0x38636000, 0x38638000, 0x3863A000,
1366 0x3863C000, 0x3863E000, 0x38640000, 0x38642000, 0x38644000, 0x38646000, 0x38648000, 0x3864A000, 0x3864C000,
1367 0x3864E000, 0x38650000, 0x38652000, 0x38654000, 0x38656000, 0x38658000, 0x3865A000, 0x3865C000, 0x3865E000,
1368 0x38660000, 0x38662000, 0x38664000, 0x38666000, 0x38668000, 0x3866A000, 0x3866C000, 0x3866E000, 0x38670000,
1369 0x38672000, 0x38674000, 0x38676000, 0x38678000, 0x3867A000, 0x3867C000, 0x3867E000, 0x38680000, 0x38682000,
1370 0x38684000, 0x38686000, 0x38688000, 0x3868A000, 0x3868C000, 0x3868E000, 0x38690000, 0x38692000, 0x38694000,
1371 0x38696000, 0x38698000, 0x3869A000, 0x3869C000, 0x3869E000, 0x386A0000, 0x386A2000, 0x386A4000, 0x386A6000,
1372 0x386A8000, 0x386AA000, 0x386AC000, 0x386AE000, 0x386B0000, 0x386B2000, 0x386B4000, 0x386B6000, 0x386B8000,
1373 0x386BA000, 0x386BC000, 0x386BE000, 0x386C0000, 0x386C2000, 0x386C4000, 0x386C6000, 0x386C8000, 0x386CA000,
1374 0x386CC000, 0x386CE000, 0x386D0000, 0x386D2000, 0x386D4000, 0x386D6000, 0x386D8000, 0x386DA000, 0x386DC000,
1375 0x386DE000, 0x386E0000, 0x386E2000, 0x386E4000, 0x386E6000, 0x386E8000, 0x386EA000, 0x386EC000, 0x386EE000,
1376 0x386F0000, 0x386F2000, 0x386F4000, 0x386F6000, 0x386F8000, 0x386FA000, 0x386FC000, 0x386FE000, 0x38700000,
1377 0x38702000, 0x38704000, 0x38706000, 0x38708000, 0x3870A000, 0x3870C000, 0x3870E000, 0x38710000, 0x38712000,
1378 0x38714000, 0x38716000, 0x38718000, 0x3871A000, 0x3871C000, 0x3871E000, 0x38720000, 0x38722000, 0x38724000,
1379 0x38726000, 0x38728000, 0x3872A000, 0x3872C000, 0x3872E000, 0x38730000, 0x38732000, 0x38734000, 0x38736000,
1380 0x38738000, 0x3873A000, 0x3873C000, 0x3873E000, 0x38740000, 0x38742000, 0x38744000, 0x38746000, 0x38748000,
1381 0x3874A000, 0x3874C000, 0x3874E000, 0x38750000, 0x38752000, 0x38754000, 0x38756000, 0x38758000, 0x3875A000,
1382 0x3875C000, 0x3875E000, 0x38760000, 0x38762000, 0x38764000, 0x38766000, 0x38768000, 0x3876A000, 0x3876C000,
1383 0x3876E000, 0x38770000, 0x38772000, 0x38774000, 0x38776000, 0x38778000, 0x3877A000, 0x3877C000, 0x3877E000,
1384 0x38780000, 0x38782000, 0x38784000, 0x38786000, 0x38788000, 0x3878A000, 0x3878C000, 0x3878E000, 0x38790000,
1385 0x38792000, 0x38794000, 0x38796000, 0x38798000, 0x3879A000, 0x3879C000, 0x3879E000, 0x387A0000, 0x387A2000,
1386 0x387A4000, 0x387A6000, 0x387A8000, 0x387AA000, 0x387AC000, 0x387AE000, 0x387B0000, 0x387B2000, 0x387B4000,
1387 0x387B6000, 0x387B8000, 0x387BA000, 0x387BC000, 0x387BE000, 0x387C0000, 0x387C2000, 0x387C4000, 0x387C6000,
1388 0x387C8000, 0x387CA000, 0x387CC000, 0x387CE000, 0x387D0000, 0x387D2000, 0x387D4000, 0x387D6000, 0x387D8000,
1389 0x387DA000, 0x387DC000, 0x387DE000, 0x387E0000, 0x387E2000, 0x387E4000, 0x387E6000, 0x387E8000, 0x387EA000,
1390 0x387EC000, 0x387EE000, 0x387F0000, 0x387F2000, 0x387F4000, 0x387F6000, 0x387F8000, 0x387FA000, 0x387FC000,
1392 static const bits<float>::type exponent_table[64] = { 0x00000000, 0x00800000, 0x01000000, 0x01800000,
1393 0x02000000, 0x02800000, 0x03000000, 0x03800000, 0x04000000, 0x04800000, 0x05000000, 0x05800000, 0x06000000,
1394 0x06800000, 0x07000000, 0x07800000, 0x08000000, 0x08800000, 0x09000000, 0x09800000, 0x0A000000, 0x0A800000,
1395 0x0B000000, 0x0B800000, 0x0C000000, 0x0C800000, 0x0D000000, 0x0D800000, 0x0E000000, 0x0E800000, 0x0F000000,
1396 0x47800000, 0x80000000, 0x80800000, 0x81000000, 0x81800000, 0x82000000, 0x82800000, 0x83000000, 0x83800000,
1397 0x84000000, 0x84800000, 0x85000000, 0x85800000, 0x86000000, 0x86800000, 0x87000000, 0x87800000, 0x88000000,
1398 0x88800000, 0x89000000, 0x89800000, 0x8A000000, 0x8A800000, 0x8B000000, 0x8B800000, 0x8C000000, 0x8C800000,
1399 0x8D000000, 0x8D800000, 0x8E000000, 0x8E800000, 0x8F000000, 0xC7800000 };
1400 static const unsigned short offset_table[64] = { 0, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024,
1401 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024,
1402 1024, 1024, 1024, 0, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024,
1403 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024 };
1405 mantissa_table[offset_table[value >> 10] + (value & 0x3FF)] + exponent_table[value >> 10];
1408 std::memcpy(&out, &fbits,
sizeof(
float));
1418 #if HALF_ENABLE_F16C_INTRINSICS
1419 return _mm_cvtsd_f64(_mm_cvtps_pd(_mm_cvtph_ps(_mm_cvtsi32_si128(value))));
1422 unsigned int abs = value & 0x7FFF;
1424 hi |= 0x3F000000 <<
static_cast<unsigned>(
abs >= 0x7C00);
1425 for (;
abs < 0x400;
abs <<= 1, hi -= 0x100000)
1431 std::memcpy(&out, &dbits,
sizeof(
double));
1443 unsigned int abs = value & 0x7FFF;
1445 out = (std::numeric_limits<T>::has_signaling_NaN && !(
abs & 0x200))
1446 ? std::numeric_limits<T>::signaling_NaN()
1447 : std::numeric_limits<T>::has_quiet_NaN ? std::numeric_limits<T>::quiet_NaN()
1449 else if (
abs == 0x7C00)
1450 out = std::numeric_limits<T>::has_infinity ? std::numeric_limits<T>::infinity()
1451 : std::numeric_limits<T>::max();
1452 else if (
abs > 0x3FF)
1456 return (value & 0x8000) ? -out : out;
1476 template <std::
float_round_style R,
bool E,
bool I,
typename T>
T half2int(
unsigned int value)
1478 unsigned int abs = value & 0x7FFF;
1479 if (
abs >= 0x7C00) {
1481 return (value & 0x8000) ? std::numeric_limits<T>::min() : std::numeric_limits<T>::max();
1485 return (
R == std::round_toward_infinity) ?
T(~(value >> 15) & (
abs != 0))
1486 : (
R == std::round_toward_neg_infinity) ? -
T(value > 0x8000)
1489 int exp = 25 - (
abs >> 10);
1490 unsigned int m = (value & 0x3FF) | 0x400;
1494 ((
R == std::round_to_nearest) ? ((1 << (
exp - 1)) - (~(m >>
exp) & E))
1495 : (
R == std::round_toward_infinity) ? (((1 <<
exp) - 1) & ((value >> 15) - 1))
1496 : (
R == std::round_toward_neg_infinity) ? (((1 <<
exp) - 1) & -(value >> 15))
1499 if ((!std::numeric_limits<T>::is_signed && (value & 0x8000)) ||
1500 (std::numeric_limits<T>::digits < 16 &&
1501 ((value & 0x8000) ? (-i < std::numeric_limits<T>::min()) : (i > std::numeric_limits<T>::max()))))
1503 else if (I &&
exp > 0 && (m & ((1 <<
exp) - 1)))
1505 return static_cast<T>((value & 0x8000) ? -i : i);
1519 uint32 xy = (x >> 16) * (y & 0xFFFF), yx = (x & 0xFFFF) * (y >> 16),
1520 c = (xy & 0xFFFF) + (yx & 0xFFFF) + (((x & 0xFFFF) * (y & 0xFFFF)) >> 16);
1521 return (x >> 16) * (y >> 16) + (xy >> 16) + (yx >> 16) + (c >> 16) +
1522 ((
R == std::round_to_nearest) ? ((c >> 15) & 1)
1523 : (
R == std::round_toward_infinity) ? ((c & 0xFFFF) != 0)
1533 #if HALF_ENABLE_CPP11_LONG_LONG
1534 return static_cast<uint32>(
1535 (
static_cast<unsigned long long>(x) *
static_cast<unsigned long long>(y) + 0x80000000) >> 32);
1537 return mulhi<std::round_to_nearest>(x, y);
1548 #if HALF_ENABLE_CPP11_LONG_LONG
1549 unsigned long long xx =
static_cast<unsigned long long>(x) << 32;
1550 return s = (xx % y != 0),
static_cast<uint32>(xx / y);
1554 for (
unsigned int i = 0; i < 32; ++i) {
1562 return s = rem > 1, div;
1573 template <
bool Q,
bool R>
unsigned int mod(
unsigned int x,
unsigned int y,
int* quo = NULL)
1577 int absx = x, absy = y, expx = 0, expy = 0;
1578 for (; absx < 0x400; absx <<= 1, --expx)
1580 for (; absy < 0x400; absy <<= 1, --expy)
1584 int mx = (absx & 0x3FF) | 0x400, my = (absy & 0x3FF) | 0x400;
1585 for (
int d = expx - expy; d; --d) {
1593 q <<= static_cast<int>(Q);
1602 q &= (1 << (std::numeric_limits<int>::digits - 1)) - 1;
1606 for (; mx < 0x400; mx <<= 1, --expy)
1608 x = (expy > 0) ? ((expy << 10) | (mx & 0x3FF)) : (mx >> (1 - expy));
1613 a = (x < 0x400) ? (x << 1) : (x + 0x400);
1619 if (a > b || (a == b && (q & 1))) {
1620 int exp = (y >> 10) + (y <= 0x3FF), d =
exp - (x >> 10) - (x <= 0x3FF);
1621 int m = (((y & 0x3FF) | ((y > 0x3FF) << 10)) << 1) - (((x & 0x3FF) | ((x > 0x3FF) << 10)) << (1 - d));
1622 for (; m < 0x800 && exp > 1; m <<= 1, --
exp)
1624 x = 0x8000 + ((
exp - 1) << 10) + (m >> 1);
1644 for (
uint32 bit =
static_cast<uint32>(1) << F; bit; bit >>= 2) {
1662 static const uint32 logs[] = { 0x80000000, 0x4AE00D1D, 0x2934F098, 0x15C01A3A, 0x0B31FB7D, 0x05AEB4DD,
1663 0x02DCF2D1, 0x016FE50B, 0x00B84E23, 0x005C3E10, 0x002E24CA, 0x001713D6, 0x000B8A47, 0x0005C53B, 0x0002E2A3,
1664 0x00017153, 0x0000B8AA, 0x00005C55, 0x00002E2B, 0x00001715, 0x00000B8B, 0x000005C5, 0x000002E3, 0x00000171,
1665 0x000000B9, 0x0000005C, 0x0000002E, 0x00000017, 0x0000000C, 0x00000006, 0x00000003, 0x00000001 };
1668 uint32 mx = 0x80000000, my = 0;
1669 for (
unsigned int i = 1; i < n; ++i) {
1670 uint32 mz = my + logs[i];
1686 static const uint32 logs[] = { 0x80000000, 0x4AE00D1D, 0x2934F098, 0x15C01A3A, 0x0B31FB7D, 0x05AEB4DD,
1687 0x02DCF2D1, 0x016FE50B, 0x00B84E23, 0x005C3E10, 0x002E24CA, 0x001713D6, 0x000B8A47, 0x0005C53B, 0x0002E2A3,
1688 0x00017153, 0x0000B8AA, 0x00005C55, 0x00002E2B, 0x00001715, 0x00000B8B, 0x000005C5, 0x000002E3, 0x00000171,
1689 0x000000B9, 0x0000005C, 0x0000002E, 0x00000017, 0x0000000C, 0x00000006, 0x00000003, 0x00000001 };
1690 if (m == 0x40000000)
1692 uint32 mx = 0x40000000, my = 0;
1693 for (
unsigned int i = 1; i < n; ++i) {
1694 uint32 mz = mx + (mx >> i);
1710 static const uint32 angles[] = { 0x3243F6A9, 0x1DAC6705, 0x0FADBAFD, 0x07F56EA7, 0x03FEAB77, 0x01FFD55C,
1711 0x00FFFAAB, 0x007FFF55, 0x003FFFEB, 0x001FFFFD, 0x00100000, 0x00080000, 0x00040000, 0x00020000, 0x00010000,
1712 0x00008000, 0x00004000, 0x00002000, 0x00001000, 0x00000800, 0x00000400, 0x00000200, 0x00000100, 0x00000080,
1713 0x00000040, 0x00000020, 0x00000010, 0x00000008, 0x00000004, 0x00000002, 0x00000001 };
1714 uint32 mx = 0x26DD3B6A, my = 0;
1715 for (
unsigned int i = 0; i < n; ++i) {
1721 mz -= (angles[i] ^ sign) - sign;
1723 return std::make_pair(my, mx);
1734 static const uint32 angles[] = { 0x3243F6A9, 0x1DAC6705, 0x0FADBAFD, 0x07F56EA7, 0x03FEAB77, 0x01FFD55C,
1735 0x00FFFAAB, 0x007FFF55, 0x003FFFEB, 0x001FFFFD, 0x00100000, 0x00080000, 0x00040000, 0x00020000, 0x00010000,
1736 0x00008000, 0x00004000, 0x00002000, 0x00001000, 0x00000800, 0x00000400, 0x00000200, 0x00000100, 0x00000080,
1737 0x00000040, 0x00000020, 0x00000010, 0x00000008, 0x00000004, 0x00000002, 0x00000001 };
1739 for (
unsigned int i = 0; i < n; ++i) {
1745 mz += (angles[i] ^ sign) - sign;
1757 int exp = (
abs >> 10) + (
abs <= 0x3FF) - 15;
1759 return k = 0, m << (
exp + 20);
1760 #if HALF_ENABLE_CPP11_LONG_LONG
1761 unsigned long long y = m * 0xA2F9836E4E442, mask = (1ULL << (62 -
exp)) - 1, yi = (y + (mask >> 1)) & ~mask,
1764 k =
static_cast<int>(yi >> (62 -
exp));
1765 return (
multiply64(
static_cast<uint32>((sign ? -f : f) >> (31 -
exp)), 0xC90FDAA2) ^ sign) - sign;
1767 uint32 yh = m * 0xA2F98 + mulhi<std::round_toward_zero>(m, 0x36E4E442), yl = (m * 0x36E4E442) & 0xFFFFFFFF;
1768 uint32 mask = (
static_cast<uint32>(1) << (30 -
exp)) - 1, yi = (yh + (mask >> 1)) & ~mask,
1769 sign = -
static_cast<uint32>(yi > yh);
1770 k =
static_cast<int>(yi >> (30 -
exp));
1771 uint32 fh = (yh ^ sign) + (yi ^ ~sign) - ~sign, fl = (yl ^ sign) - sign;
1772 return (
multiply64((
exp > -1) ? (((fh << (1 +
exp)) & 0xFFFFFFFF) | ((fl & 0xFFFFFFFF) >> (31 -
exp))) : fh,
1788 uint32 my = ((
abs & 0x3FF) | 0x400) << 5, r = my * my;
1790 r = 0x40000000 - ((rexp > -31) ? ((r >> -rexp) | ((r & ((
static_cast<uint32>(1) << -rexp) - 1)) != 0)) : 1);
1791 for (rexp = 0; r < 0x40000000; r <<= 1, --rexp)
1793 uint32 mx = sqrt<30>(r, rexp);
1796 return std::make_pair((d < -14) ? ((my >> (-d - 14)) + ((my >> (-d - 15)) & 1)) : (my << (14 + d)),
1797 (mx << 14) + (r << 13) / mx);
1799 return std::make_pair(my << 14,
1800 (d > 14) ? ((mx >> (d - 14)) + ((mx >> (d - 15)) & 1))
1801 : ((d == 14) ? mx : ((mx << (14 - d)) + (r << (13 - d)) / mx)));
1802 return std::make_pair(my << 13, (mx << 13) + (r << 12) / mx);
1814 int e = (
abs >> 10) + (
abs <= 0x3FF);
1819 exp = mx >> (45 - e);
1820 mx = (mx << (e - 14)) & 0x7FFFFFFF;
1823 int d =
exp << 1, s;
1824 if (mx > 0x80000000) {
1830 return std::make_pair(mx, (d < 31) ? ((my >> d) | ((my & ((
static_cast<uint32>(1) << d) - 1)) != 0)) : 1);
1844 template <std::
float_round_style R>
1850 return underflow<R>(sign);
1851 else if (
exp == -25)
1852 return rounded<R, false>(sign, 1, m != 0);
1853 }
else if (
exp > 15)
1854 return overflow<R>(sign);
1861 return fixed2half<R, 31, false, false, true>(m,
exp + 14, sign, s);
1875 template <std::
float_round_style R, u
int32 L>
1879 m = (((
static_cast<uint32>(ilog) << 27) + (m >> 4)) ^ msign) - msign;
1882 for (; m < 0x80000000; m <<= 1, --
exp)
1887 sign ^= msign & 0x8000;
1889 return underflow<R>(sign);
1891 return fixed2half<R, 30, false, false, true>(m,
exp, sign, 1);
1905 if ((
exp += i) > 46)
1906 return overflow<R>();
1908 return underflow<R>();
1909 r = (r >> i) | (r & i);
1911 return fixed2half<R, 15, false, false, false>(m,
exp - 1, 0, r != 0);
1926 int i = my >= mx, s;
1929 return overflow<R>(sign);
1931 return underflow<R>(sign);
1933 return fixed2half<R, 30, false, false, true>(m,
exp, sign, s);
1945 template <std::
float_round_style R,
bool S>
unsigned int area(
unsigned int arg)
1947 int abs = arg & 0x7FFF, expx = (
abs >> 10) + (
abs <= 0x3FF) - 15, expy = -15, ilog, i;
1949 for (;
abs < 0x400;
abs <<= 1, --expy)
1952 r = ((
abs & 0x3FF) | 0x400) << 5;
1955 expy = 2 * expy + i;
1960 ((expy > -30) ? ((r >> -expy) | ((r & ((
static_cast<uint32>(1) << -expy) - 1)) != 0)) : 1);
1963 r += 0x40000000 >> expy;
1965 r = (r >> i) | (r & i);
1969 r -= 0x40000000 >> expy;
1970 for (; r < 0x40000000; r <<= 1, --expy)
1973 my = sqrt<30>(r, expy);
1974 my = (my << 15) + (r << 14) / my;
1984 static const int G =
S && (
R == std::round_to_nearest);
1985 return log2_post<R, 0xB8AA3B2A>(
1986 log2(my >> i, 26 +
S + G) + (G << 3), ilog + i, 17, arg & (
static_cast<unsigned>(
S) << 15));
2007 m =
static_cast<uint32>((
abs & 0x3FF) | 0x400) << 21;
2020 uint32 m = a.
m + ((d < 32) ? (b.
m >> d) : 0);
2021 int i = (
m & 0xFFFFFFFF) < a.
m;
2022 return f31(((
m + i) >> i) | 0x80000000, a.
exp + i);
2032 uint32 m = a.
m - ((d < 32) ? (b.
m >> d) : 0);
2035 for (;
m < 0x80000000;
m <<= 1, --
exp)
2057 int i = a.
m >= b.
m, s;
2076 template <std::
float_round_style R,
bool C>
unsigned int erf(
unsigned int arg)
2078 unsigned int abs = arg & 0x7FFF, sign = arg & 0x8000;
2079 f31 x(
abs), x2 = x * x *
f31(0xB8AA3B29, 0),
2080 t =
f31(0x80000000, 0) / (
f31(0x80000000, 0) +
f31(0xA7BA054A, -2) * x), t2 = t * t;
2081 f31 e = ((
f31(0x87DC2213, 0) * t2 +
f31(0xB5F0E2AE, 0)) * t2 +
f31(0x82790637, -2) -
2082 (
f31(0xBA00E2B8, 0) * t2 +
f31(0x91A98E62, -2)) * t) *
2085 :
f31(
exp2((x2.
m << x2.
exp) & 0x7FFFFFFF, 22), x2.
m >> (31 - x2.
exp)));
2087 ? fixed2half<R, 31, false, true, true>(0x80000000 - (e.
m >> (C - e.
exp)), 14 + C, sign & (C - 1U))
2088 : (e.
exp < -25) ? underflow<R>()
2089 : fixed2half<R, 30, false, false, true>(e.
m >> 1, e.
exp + 14, 0, e.
m & 1);
2101 template <std::
float_round_style R,
bool L>
unsigned int gamma(
unsigned int arg)
2108 static const f31 pi(0xC90FDAA2, 1), lbe(0xB8AA3B29, 0);
2109 unsigned int abs = arg & 0x7FFF, sign = arg & 0x8000;
2110 bool bsign = sign != 0;
2111 f31 z(
abs), x = sign ? (z +
f31(0x80000000, 0)) : z, t = x +
f31(0x94CCCCCD, 2),
2112 s =
f31(0xA06C9901, 1) +
f31(0xBBE654E2, -7) / (x +
f31(0x80000000, 2)) +
2113 f31(0xA1CE6098, 6) / (x +
f31(0x80000000, 1)) +
f31(0xE1868CB7, 7) / x -
2114 f31(0x8625E279, 8) / (x +
f31(0x80000000, 0)) -
f31(0xA03E158F, 2) / (x +
f31(0xC0000000, 1));
2115 int i = (s.exp >= 2) + (s.exp >= 4) + (s.exp >= 8) + (s.exp >= 16);
2116 s =
f31((
static_cast<uint32>(s.exp) << (31 - i)) + (
log2(s.m >> 1, 28) >> i), i) / lbe;
2117 if (x.
exp != -1 || x.
m != 0x80000000) {
2118 i = (t.exp >= 2) + (t.exp >= 4) + (t.exp >= 8);
2119 f31 l =
f31((
static_cast<uint32>(t.exp) << (31 - i)) + (
log2(t.m >> 1, 30) >> i), i) / lbe;
2120 s = (x.
exp < -1) ? (s - (
f31(0x80000000, -1) - x) * l) : (s + (x -
f31(0x80000000, -1)) * l);
2122 s = x.
exp ? (s - t) : (t - s);
2125 sign &= (L | ((z.m >> (31 - z.exp)) & 1)) - 1;
2126 for (z =
f31((z.m << (1 + z.exp)) & 0xFFFFFFFF, -1); z.
m < 0x80000000; z.m <<= 1, --z.exp)
2130 z =
f31(0x80000000, 0) - z;
2133 z.
m =
sincos(z.m >> (1 - z.exp), 30).first;
2134 for (z.exp = 1; z.m < 0x80000000; z.m <<= 1, --z.exp)
2137 z =
f31(0x80000000, 0);
2141 f31 l(0x92868247, 0);
2144 z =
f31(-((
static_cast<uint32>(z.exp) << 26) + (m >> 5)), 5);
2145 for (; z.m < 0x80000000; z.m <<= 1, --z.exp)
2149 sign =
static_cast<unsigned>(x.
exp && (l.
exp < s.exp || (l.
exp == s.exp && l.
m < s.m))) << 15;
2150 s = sign ? (s - l) : x.
exp ? (l - s) : (l + s);
2152 sign =
static_cast<unsigned>(x.
exp == 0) << 15;
2154 return underflow<R>(sign);
2156 return overflow<R>(sign);
2165 m = (s.m << s.exp) & 0x7FFFFFFF;
2166 s.exp = (s.m >> (31 - s.exp));
2170 s =
f31(0x80000000, 0) / s;
2176 return underflow<R>(sign);
2177 }
else if (z.exp > 0 && !(z.m & ((1 << (31 - z.exp)) - 1)))
2178 return ((s.exp + 14) << 10) + (s.m >> 21);
2180 return overflow<R>(sign);
2182 return fixed2half<R, 31, false, false, true>(s.m, s.exp + 14, sign);
2186 template <
typename,
typename, std::
float_round_style>
struct half_caster;
2226 operator float()
const {
return detail::half2float<float>(
data_); }
2340 #ifndef HALF_DOXYGEN_ONLY
2352 template <
typename charT,
typename traits>
2353 friend std::basic_ostream<charT, traits>&
operator<<(std::basic_ostream<charT, traits>&,
half);
2354 template <
typename charT,
typename traits>
2355 friend std::basic_istream<charT, traits>&
operator>>(std::basic_istream<charT, traits>&,
half&);
2404 #ifdef HALF_ENABLE_CPP11_LONG_LONG
2405 friend long long llround(
half);
2406 friend long long llrint(
half);
2428 friend class std::numeric_limits<
half>;
2429 #if HALF_ENABLE_CPP11_HASH
2430 friend struct std::hash<
half>;
2432 #if HALF_ENABLE_CPP11_USER_LITERALS
2433 friend half literal::operator
"" _h(
long double);
2438 #if HALF_ENABLE_CPP11_USER_LITERALS
2447 inline half operator"" _h(
long double value)
2461 template <
typename T,
typename U, std::
float_round_style R = (std::
float_round_style)(HALF_ROUND_STYLE)>
2464 #if HALF_ENABLE_CPP11_STATIC_ASSERT && HALF_ENABLE_CPP11_TYPE_TRAITS
2465 static_assert(std::is_arithmetic<U>::value,
"half_cast from non-arithmetic type unsupported");
2475 #if HALF_ENABLE_CPP11_STATIC_ASSERT && HALF_ENABLE_CPP11_TYPE_TRAITS
2476 static_assert(std::is_arithmetic<T>::value,
"half_cast to non-arithmetic type unsupported");
2533 #if HALF_ERRHANDLING_THROWS
2625 #if HALF_ENABLE_CPP11_HASH
2635 typedef size_t result_type;
2640 result_type operator()(argument_type arg)
const
2642 return hash<half_float::detail::uint16>()(arg.data_ & -
static_cast<unsigned>(arg.data_ != 0x8000));
2684 ((x.
data_ ^ (0x8000 | (0x8000 - (x.
data_ >> 15)))) + (x.
data_ >> 15)) <
2685 ((y.
data_ ^ (0x8000 | (0x8000 - (y.
data_ >> 15)))) + (y.
data_ >> 15));
2697 ((x.
data_ ^ (0x8000 | (0x8000 - (x.
data_ >> 15)))) + (x.
data_ >> 15)) >
2698 ((y.
data_ ^ (0x8000 | (0x8000 - (y.
data_ >> 15)))) + (y.
data_ >> 15));
2710 ((x.
data_ ^ (0x8000 | (0x8000 - (x.
data_ >> 15)))) + (x.
data_ >> 15)) <=
2711 ((y.
data_ ^ (0x8000 | (0x8000 - (y.
data_ >> 15)))) + (y.
data_ >> 15));
2723 ((x.
data_ ^ (0x8000 | (0x8000 - (x.
data_ >> 15)))) + (x.
data_ >> 15)) >=
2724 ((y.
data_ ^ (0x8000 | (0x8000 - (y.
data_ >> 15)))) + (y.
data_ >> 15));
2751 #ifdef HALF_ARITHMETIC_TYPE
2753 detail::float2half<half::round_style>(
2754 detail::half2float<detail::internal_t>(x.
data_) + detail::half2float<detail::internal_t>(y.
data_)));
2756 int absx = x.
data_ & 0x7FFF, absy = y.
data_ & 0x7FFF;
2757 bool sub = ((x.
data_ ^ y.
data_) & 0x8000) != 0;
2758 if (absx >= 0x7C00 || absy >= 0x7C00)
2761 : (absy != 0x7C00) ? x.
data_
2771 unsigned int sign = ((sub && absy > absx) ? y.
data_ : x.
data_) & 0x8000;
2773 std::swap(absx, absy);
2774 int exp = (absx >> 10) + (absx <= 0x3FF), d =
exp - (absy >> 10) - (absy <= 0x3FF),
2775 mx = ((absx & 0x3FF) | ((absx > 0x3FF) << 10)) << 3, my;
2777 my = ((absy & 0x3FF) | ((absy > 0x3FF) << 10)) << 3;
2778 my = (my >> d) | ((my & ((1 << d) - 1)) != 0);
2785 for (; mx < 0x2000 && exp > 1; mx <<= 1, --
exp)
2790 if ((
exp += i) > 30)
2792 mx = (mx >> i) | (mx & i);
2795 detail::rounded<half::round_style, false>(
2796 sign + ((
exp - 1) << 10) + (mx >> 3), (mx >> 2) & 1, (mx & 0x3) != 0));
2809 #ifdef HALF_ARITHMETIC_TYPE
2811 detail::float2half<half::round_style>(
2812 detail::half2float<detail::internal_t>(x.
data_) - detail::half2float<detail::internal_t>(y.
data_)));
2827 #ifdef HALF_ARITHMETIC_TYPE
2829 detail::float2half<half::round_style>(
2830 detail::half2float<detail::internal_t>(x.
data_) * detail::half2float<detail::internal_t>(y.
data_)));
2832 int absx = x.
data_ & 0x7FFF, absy = y.
data_ & 0x7FFF,
exp = -16;
2833 unsigned int sign = (x.
data_ ^ y.
data_) & 0x8000;
2834 if (absx >= 0x7C00 || absy >= 0x7C00)
2837 : ((absx == 0x7C00 && !absy) || (absy == 0x7C00 && !absx)) ?
detail::invalid()
2841 for (; absx < 0x400; absx <<= 1, --
exp)
2843 for (; absy < 0x400; absy <<= 1, --
exp)
2847 int i = m >> 21, s = m & i;
2848 exp += (absx >> 10) + (absy >> 10) + i;
2853 return half(
detail::binary, detail::fixed2half<half::round_style, 20, false, false, false>(m >> i,
exp, sign, s));
2867 #ifdef HALF_ARITHMETIC_TYPE
2869 detail::float2half<half::round_style>(
2870 detail::half2float<detail::internal_t>(x.
data_) / detail::half2float<detail::internal_t>(y.
data_)));
2872 int absx = x.
data_ & 0x7FFF, absy = y.
data_ & 0x7FFF,
exp = 14;
2873 unsigned int sign = (x.
data_ ^ y.
data_) & 0x8000;
2874 if (absx >= 0x7C00 || absy >= 0x7C00)
2878 : (sign | ((absx == 0x7C00) ? 0x7C00 : 0)));
2883 for (; absx < 0x400; absx <<= 1, --
exp)
2885 for (; absy < 0x400; absy <<= 1, ++
exp)
2887 detail::uint32 mx = (absx & 0x3FF) | 0x400, my = (absy & 0x3FF) | 0x400;
2889 exp += (absx >> 10) - (absy >> 10) - i;
2897 detail::fixed2half<half::round_style, 11, false, false, false>(mx / my,
exp, sign, mx % my != 0));
2911 template <
typename charT,
typename traits>
2912 std::basic_ostream<charT, traits>&
operator<<(std::basic_ostream<charT, traits>& out,
half arg)
2914 #ifdef HALF_ARITHMETIC_TYPE
2915 return out << detail::half2float<detail::internal_t>(arg.
data_);
2917 return out << detail::half2float<float>(arg.
data_);
2930 template <
typename charT,
typename traits>
2931 std::basic_istream<charT, traits>&
operator>>(std::basic_istream<charT, traits>& in,
half& arg)
2933 #ifdef HALF_ARITHMETIC_TYPE
2934 detail::internal_t f;
2939 arg.
data_ = detail::float2half<half::round_style>(f);
2968 unsigned int absx = x.
data_ & 0x7FFF, absy = y.
data_ & 0x7FFF, sign = x.
data_ & 0x8000;
2969 if (absx >= 0x7C00 || absy >= 0x7C00)
2991 unsigned int absx = x.
data_ & 0x7FFF, absy = y.
data_ & 0x7FFF, sign = x.
data_ & 0x8000;
2992 if (absx >= 0x7C00 || absy >= 0x7C00)
3013 unsigned int absx = x.
data_ & 0x7FFF, absy = y.
data_ & 0x7FFF, value = x.
data_ & 0x8000;
3014 if (absx >= 0x7C00 || absy >= 0x7C00)
3018 : (*quo = 0, x.
data_));
3021 bool qsign = ((value ^ y.
data_) & 0x8000) != 0;
3024 value ^= detail::mod<true, true>(absx, absy, &q);
3040 #ifdef HALF_ARITHMETIC_TYPE
3041 detail::internal_t fx = detail::half2float<detail::internal_t>(x.
data_),
3042 fy = detail::half2float<detail::internal_t>(y.
data_),
3043 fz = detail::half2float<detail::internal_t>(z.
data_);
3044 #if HALF_ENABLE_CPP11_CMATH && FP_FAST_FMA
3050 int absx = x.
data_ & 0x7FFF, absy = y.
data_ & 0x7FFF, absz = z.
data_ & 0x7FFF,
exp = -15;
3051 unsigned int sign = (x.
data_ ^ y.
data_) & 0x8000;
3052 bool sub = ((sign ^ z.
data_) & 0x8000) != 0;
3053 if (absx >= 0x7C00 || absy >= 0x7C00 || absz >= 0x7C00)
3054 return (absx > 0x7C00 || absy > 0x7C00 || absz > 0x7C00)
3065 for (; absx < 0x400; absx <<= 1, --
exp)
3067 for (; absy < 0x400; absy <<= 1, --
exp)
3072 exp += (absx >> 10) + (absy >> 10) + i;
3076 for (; absz < 0x400; absz <<= 1, --expz)
3080 if (expz >
exp || (expz ==
exp && mz > m)) {
3082 std::swap(
exp, expz);
3084 sign = z.
data_ & 0x8000;
3087 mz = (d < 23) ? ((mz >> d) | ((mz & ((
static_cast<detail::uint32>(1) << d) - 1)) != 0)) : 1;
3093 for (; m < 0x800000; m <<= 1, --
exp)
3098 m = (m >> i) | (m & i);
3106 return half(
detail::binary, detail::fixed2half<half::round_style, 23, false, false, false>(m,
exp - 1, sign));
3121 (x.
data_ ^ (0x8000 | (0x8000 - (x.
data_ >> 15)))) < (y.
data_ ^ (0x8000 | (0x8000 - (y.
data_ >> 15))))))
3137 (x.
data_ ^ (0x8000 | (0x8000 - (x.
data_ >> 15)))) > (y.
data_ ^ (0x8000 | (0x8000 - (y.
data_ >> 15))))))
3154 return (x.
data_ ^ (0x8000 | (0x8000 - (x.
data_ >> 15)))) <= (y.
data_ ^ (0x8000 | (0x8000 - (y.
data_ >> 15))))
3165 unsigned int value = 0x7FFF;
3167 value ^=
static_cast<unsigned>(*arg++) & 0xFF;
3186 #ifdef HALF_ARITHMETIC_TYPE
3188 detail::float2half<half::round_style>(
std::exp(detail::half2float<detail::internal_t>(arg.
data_))));
3197 (arg.
data_ & 0x8000) ? detail::underflow<half::round_style>() : detail::overflow<half::round_style>());
3204 exp = m >> (45 - e);
3205 m = (m << (e - 14)) & 0x7FFFFFFF;
3221 #if defined(HALF_ARITHMETIC_TYPE) && HALF_ENABLE_CPP11_CMATH
3223 detail::float2half<half::round_style>(
std::exp2(detail::half2float<detail::internal_t>(arg.
data_))));
3232 (arg.
data_ & 0x8000) ? detail::underflow<half::round_style>() : detail::overflow<half::round_style>());
3234 detail::exp2_post<half::round_style>((
static_cast<detail::uint32>(
exp) << (6 + e)) & 0x7FFFFFFF,
3235 exp >> (25 - e), (arg.
data_ & 0x8000) != 0, 0, 28));
3250 #if defined(HALF_ARITHMETIC_TYPE) && HALF_ENABLE_CPP11_CMATH
3252 detail::float2half<half::round_style>(
std::expm1(detail::half2float<detail::internal_t>(arg.
data_))));
3261 (arg.
data_ & 0x8000) ? detail::rounded<half::round_style, true>(0xBBFF, 1, 1)
3262 : detail::overflow<half::round_style>());
3269 exp = m >> (45 - e);
3270 m = (m << (e - 14)) & 0x7FFFFFFF;
3275 if (m > 0x80000000) {
3279 m = 0x80000000 - ((m >>
exp) | ((m & ((
static_cast<detail::uint32>(1) <<
exp) - 1)) != 0) | s);
3282 m -= (
exp < 31) ? (0x80000000 >>
exp) : 1;
3283 for (
exp += 14; m < 0x80000000 &&
exp; m <<= 1, --
exp)
3288 detail::rounded<half::round_style, true>(sign + (
exp << 10) + (m >> 21), (m >> 20) & 1, (m & 0xFFFFF) != 0));
3303 #ifdef HALF_ARITHMETIC_TYPE
3305 detail::float2half<half::round_style>(
std::log(detail::half2float<detail::internal_t>(arg.
data_))));
3310 if (arg.
data_ & 0x8000)
3318 detail::log2_post<half::round_style, 0xB8AA3B2A>(
3334 #ifdef HALF_ARITHMETIC_TYPE
3336 detail::float2half<half::round_style>(
std::log10(detail::half2float<detail::internal_t>(arg.
data_))));
3341 if (arg.
data_ & 0x8000)
3359 detail::log2_post<half::round_style, 0xD49A784C>(
3375 #if defined(HALF_ARITHMETIC_TYPE) && HALF_ENABLE_CPP11_CMATH
3377 detail::float2half<half::round_style>(
std::log2(detail::half2float<detail::internal_t>(arg.
data_))));
3382 if (arg.
data_ & 0x8000)
3391 if (!(
abs & 0x3FF)) {
3392 unsigned int value =
static_cast<unsigned>(
exp < 0) << 15, m =
std::abs(
exp) << 6;
3393 for (
exp = 18; m < 0x400; m <<= 1, --
exp)
3398 m = (((ilog << 27) +
3404 for (
exp = 14; m < 0x8000000 &&
exp; m <<= 1, --
exp)
3406 for (; m > 0xFFFFFFF; m >>= 1, ++
exp)
3409 detail::binary, detail::fixed2half<half::round_style, 27, false, false, true>(m,
exp, sign & 0x8000, s));
3425 #if defined(HALF_ARITHMETIC_TYPE) && HALF_ENABLE_CPP11_CMATH
3427 detail::float2half<half::round_style>(
std::log1p(detail::half2float<detail::internal_t>(arg.
data_))));
3429 if (arg.
data_ >= 0xBC00)
3435 if (!
abs ||
abs >= 0x7C00)
3441 if (arg.
data_ & 0x8000) {
3442 m = 0x40000000 - (m >> -
exp);
3443 for (
exp = 0; m < 0x40000000; m <<= 1, --
exp)
3447 m = 0x40000000 + (m >> -
exp);
3450 m += 0x40000000 >>
exp;
3475 #ifdef HALF_ARITHMETIC_TYPE
3477 detail::float2half<half::round_style>(
std::sqrt(detail::half2float<detail::internal_t>(arg.
data_))));
3488 m = detail::sqrt<20>(r,
exp +=
abs >> 10);
3489 return half(
detail::binary, detail::rounded<half::round_style, false>((
exp << 10) + (m & 0x3FF), r > m, r != 0));
3502 #ifdef HALF_ARITHMETIC_TYPE
3504 detail::float2half<half::round_style>(
3505 detail::internal_t(1) /
std::sqrt(detail::half2float<detail::internal_t>(arg.
data_))));
3507 unsigned int abs = arg.
data_ & 0x7FFF, bias = 0x4000;
3514 for (;
abs < 0x400;
abs <<= 1, bias -= 0x400)
3516 unsigned int frac = (
abs += bias) & 0x7FF;
3519 if ((
half::round_style == std::round_to_nearest && (frac == 0x3FE || frac == 0x76C)) ||
3521 (frac == 0x15A || frac == 0x3FC || frac == 0x401 || frac == 0x402 || frac == 0x67B)))
3523 detail::uint32 f = 0x17376 -
abs, mx = (
abs & 0x3FF) | 0x400, my = ((f >> 1) & 0x3FF) | 0x400, mz = my * my;
3524 int expy = (f >> 11) - 31, expx = 32 - (
abs >> 10), i = mz >> 21;
3525 for (mz = 0x60000000 - (((mz >> i) * mx) >> (expx - 2 * expy - i)); mz < 0x40000000; mz <<= 1, --expy)
3527 i = (my *= mz >> 10) >> 31;
3529 my = (my >> (20 + i)) + 1;
3530 i = (mz = my * my) >> 21;
3531 for (mz = 0x60000000 - (((mz >> i) * mx) >> (expx - 2 * expy - i)); mz < 0x40000000; mz <<= 1, --expy)
3533 i = (my *= (mz >> 10) + 1) >> 31;
3534 return half(
detail::binary, detail::fixed2half<half::round_style, 30, false, false, true>(my >> i, expy + i + 14));
3548 #if defined(HALF_ARITHMETIC_TYPE) && HALF_ENABLE_CPP11_CMATH
3550 detail::float2half<half::round_style>(
std::cbrt(detail::half2float<detail::internal_t>(arg.
data_))));
3553 if (!
abs ||
abs == 0x3C00 ||
abs >= 0x7C00)
3558 m = (((ilog << 27) +
3562 for (
exp = 2; m < 0x80000000; m <<= 1, --
exp)
3572 f = (m <<
exp) & 0x7FFFFFFF;
3577 if (m > 0x80000000) {
3585 ? detail::fixed2half<half::round_style, 31, false, false, false>(m,
exp + 14, arg.
data_ & 0x8000)
3586 : detail::fixed2half<half::round_style, 23, false, false, false>(
3587 (m + 0x80) >> 8,
exp + 14, arg.
data_ & 0x8000));
3602 #ifdef HALF_ARITHMETIC_TYPE
3603 detail::internal_t fx = detail::half2float<detail::internal_t>(x.
data_),
3604 fy = detail::half2float<detail::internal_t>(y.
data_);
3605 #if HALF_ENABLE_CPP11_CMATH
3611 int absx = x.
data_ & 0x7FFF, absy = y.
data_ & 0x7FFF, expx = 0, expy = 0;
3612 if (absx >= 0x7C00 || absy >= 0x7C00)
3622 std::swap(absx, absy);
3623 for (; absx < 0x400; absx <<= 1, --expx)
3625 for (; absy < 0x400; absy <<= 1, --expy)
3627 detail::uint32 mx = (absx & 0x3FF) | 0x400, my = (absy & 0x3FF) | 0x400;
3630 int ix = mx >> 21, iy = my >> 21;
3631 expx = 2 * (expx + (absx >> 10)) - 15 + ix;
3632 expy = 2 * (expy + (absy >> 10)) - 15 + iy;
3635 int d = expx - expy;
3636 my = (d < 30) ? ((my >> d) | ((my & ((
static_cast<detail::uint32>(1) << d) - 1)) != 0)) : 1;
3653 #ifdef HALF_ARITHMETIC_TYPE
3654 detail::internal_t fx = detail::half2float<detail::internal_t>(x.
data_),
3655 fy = detail::half2float<detail::internal_t>(y.
data_),
3656 fz = detail::half2float<detail::internal_t>(z.
data_);
3659 int absx = x.
data_ & 0x7FFF, absy = y.
data_ & 0x7FFF, absz = z.
data_ & 0x7FFF, expx = 0, expy = 0, expz = 0;
3666 if (absx >= 0x7C00 || absy >= 0x7C00 || absz >= 0x7C00)
3673 std::swap(absy, absz);
3675 std::swap(absx, absy);
3677 std::swap(absy, absz);
3678 for (; absx < 0x400; absx <<= 1, --expx)
3680 for (; absy < 0x400; absy <<= 1, --expy)
3682 for (; absz < 0x400; absz <<= 1, --expz)
3684 detail::uint32 mx = (absx & 0x3FF) | 0x400, my = (absy & 0x3FF) | 0x400, mz = (absz & 0x3FF) | 0x400;
3688 int ix = mx >> 21, iy = my >> 21, iz = mz >> 21;
3689 expx = 2 * (expx + (absx >> 10)) - 15 + ix;
3690 expy = 2 * (expy + (absy >> 10)) - 15 + iy;
3691 expz = 2 * (expz + (absz >> 10)) - 15 + iz;
3695 int d = expy - expz;
3696 mz = (d < 30) ? ((mz >> d) | ((mz & ((
static_cast<detail::uint32>(1) << d) - 1)) != 0)) : 1;
3698 if (my & 0x80000000) {
3699 my = (my >> 1) | (my & 1);
3700 if (++expy > expx) {
3702 std::swap(expx, expy);
3706 my = (d < 30) ? ((my >> d) | ((my & ((
static_cast<detail::uint32>(1) << d) - 1)) != 0)) : 1;
3723 #ifdef HALF_ARITHMETIC_TYPE
3725 detail::float2half<half::round_style>(
std::pow(
3726 detail::half2float<detail::internal_t>(x.
data_), detail::half2float<detail::internal_t>(y.
data_))));
3728 int absx = x.
data_ & 0x7FFF, absy = y.
data_ & 0x7FFF,
exp = -15;
3729 if (!absy || x.
data_ == 0x3C00)
3731 bool is_int = absy >= 0x6400 || (absy >= 0x3C00 && !(absy & ((1 << (25 - (absy >> 10))) - 1)));
3733 x.
data_ & (
static_cast<unsigned>((absy < 0x6800) && is_int && ((absy >> (25 - (absy >> 10))) & 1)) << 15);
3734 if (absx >= 0x7C00 || absy >= 0x7C00)
3738 ? ((absx == 0x3C00) ? 0x3C00
3740 : (0x7C00 & -((y.
data_ >> 15) ^ (absx > 0x3C00))))
3741 : (sign | (0x7C00 & ((y.
data_ >> 15) - 1U))));
3744 if ((x.
data_ & 0x8000) && !is_int)
3746 if (x.
data_ == 0xBC00)
3758 for (; absx < 0x400; absx <<= 1, --
exp)
3761 m = (((ilog << 27) +
3765 for (
exp = -11; m < 0x80000000; m <<= 1, --
exp)
3767 for (; absy < 0x400; absy <<= 1, --
exp)
3771 exp += (absy >> 10) + i;
3777 f = (m <<
exp) & 0x7FFFFFFF;
3781 detail::binary, detail::exp2_post<half::round_style>(f,
exp, ((msign & 1) ^ (y.
data_ >> 15)) != 0, sign));
3801 #ifdef HALF_ARITHMETIC_TYPE
3802 detail::internal_t f = detail::half2float<detail::internal_t>(arg.
data_);
3812 }
else if (
abs < 0x2500) {
3820 detail::binary, detail::rounded<half::round_style, true>((~arg.
data_ & 0x8000) | 0x1D07, 1, 1));
3830 detail::binary, detail::rounded<half::round_style, true>((~arg.
data_ & 0x8000) | 0x3BFE, 1, 1));
3843 sc = std::make_pair(sc.second, -sc.first);
3846 sc = std::make_pair(-sc.first, -sc.second);
3849 sc = std::make_pair(-sc.second, sc.first);
3853 detail::fixed2half<half::round_style, 30, true, true, true>(
3855 *
cos =
half(
detail::binary, detail::fixed2half<half::round_style, 30, true, true, true>(sc.second));
3870 #ifdef HALF_ARITHMETIC_TYPE
3872 detail::float2half<half::round_style>(
std::sin(detail::half2float<detail::internal_t>(arg.
data_))));
3893 detail::fixed2half<half::round_style, 30, true, true, true>((((k & 1) ? sc.second : sc.first) ^ sign) - sign));
3907 #ifdef HALF_ARITHMETIC_TYPE
3909 detail::float2half<half::round_style>(
std::cos(detail::half2float<detail::internal_t>(arg.
data_))));
3923 detail::fixed2half<half::round_style, 30, true, true, true>((((k & 1) ? sc.first : sc.second) ^ sign) - sign));
3937 #ifdef HALF_ARITHMETIC_TYPE
3939 detail::float2half<half::round_style>(
std::tan(detail::half2float<detail::internal_t>(arg.
data_))));
3957 sc = std::make_pair(-sc.second, sc.first);
3959 detail::uint32 my = (sc.first ^ signy) - signy, mx = (sc.second ^ signx) - signx;
3960 for (; my < 0x80000000; my <<= 1, --
exp)
3962 for (; mx < 0x80000000; mx <<= 1, ++
exp)
3965 detail::binary, detail::tangent_post<half::round_style>(my, mx,
exp, (signy ^ signx ^ arg.
data_) & 0x8000));
3979 #ifdef HALF_ARITHMETIC_TYPE
3981 detail::float2half<half::round_style>(
std::asin(detail::half2float<detail::internal_t>(arg.
data_))));
3983 unsigned int abs = arg.
data_ & 0x7FFF, sign = arg.
data_ & 0x8000;
3990 : detail::rounded<half::round_style, true>(sign | 0x3E48, 0, 1));
3997 return half(
detail::binary, detail::fixed2half<half::round_style, 30, false, true, true>(m, 14, sign));
4011 #ifdef HALF_ARITHMETIC_TYPE
4013 detail::float2half<half::round_style>(
std::acos(detail::half2float<detail::internal_t>(arg.
data_))));
4015 unsigned int abs = arg.
data_ & 0x7FFF, sign = arg.
data_ >> 15;
4022 : sign ? detail::rounded<half::round_style, true>(0x4248, 0, 1)
4027 detail::fixed2half<half::round_style, 31, false, true, true>(sign ? (0xC90FDAA2 - m) : m, 15, 0, sign));
4041 #ifdef HALF_ARITHMETIC_TYPE
4043 detail::float2half<half::round_style>(
std::atan(detail::half2float<detail::internal_t>(arg.
data_))));
4045 unsigned int abs = arg.
data_ & 0x7FFF, sign = arg.
data_ & 0x8000;
4050 (
abs == 0x7C00) ? detail::rounded<half::round_style, true>(sign | 0x3E48, 0, 1)
4059 return half(
detail::binary, detail::fixed2half<half::round_style, 30, false, true, true>(m, 14, sign));
4075 #ifdef HALF_ARITHMETIC_TYPE
4077 detail::float2half<half::round_style>(
std::atan2(
4078 detail::half2float<detail::internal_t>(y.
data_), detail::half2float<detail::internal_t>(x.
data_))));
4080 unsigned int absx = x.
data_ & 0x7FFF, absy = y.
data_ & 0x7FFF, signx = x.
data_ >> 15, signy = y.
data_ & 0x8000;
4081 if (absx >= 0x7C00 || absy >= 0x7C00) {
4082 if (absx > 0x7C00 || absy > 0x7C00)
4086 (absx < 0x7C00) ? detail::rounded<half::round_style, true>(signy | 0x3E48, 0, 1)
4087 : signx ? detail::rounded<half::round_style, true>(signy | 0x40B6, 0, 1)
4088 : detail::rounded<half::round_style, true>(signy | 0x3A48, 0, 1));
4089 return (x.
data_ == 0x7C00)
4091 :
half(
detail::binary, detail::rounded<half::round_style, true>(signy | 0x4248, 0, 1));
4094 return signx ?
half(
detail::binary, detail::rounded<half::round_style, true>(signy | 0x4248, 0, 1)) : y;
4096 return half(
detail::binary, detail::rounded<half::round_style, true>(signy | 0x3E48, 0, 1));
4097 int d = (absy >> 10) + (absy <= 0x3FF) - (absx >> 10) - (absx <= 0x3FF);
4098 if (d > (signx ? 18 : 12))
4099 return half(
detail::binary, detail::rounded<half::round_style, true>(signy | 0x3E48, 0, 1));
4100 if (signx && d < -11)
4101 return half(
detail::binary, detail::rounded<half::round_style, true>(signy | 0x4248, 0, 1));
4103 for (; absy < 0x400; absy <<= 1, --d)
4105 detail::uint32 mx = ((absx << 1) & 0x7FF) | 0x800, my = ((absy << 1) & 0x7FF) | 0x800;
4112 detail::fixed2half<half::round_style, 11, false, false, true>(my / mx, d + 14, signy, my % mx != 0));
4118 ((absx & 0x3FF) | ((absx > 0x3FF) << 10)) << (19 -
4123 detail::fixed2half<half::round_style, 31, false, true, true>(signx ? (0xC90FDAA2 - m) : m, 15, signy, signx));
4142 #ifdef HALF_ARITHMETIC_TYPE
4144 detail::float2half<half::round_style>(
std::sinh(detail::half2float<detail::internal_t>(arg.
data_))));
4147 if (!
abs ||
abs >= 0x7C00)
4151 std::pair<detail::uint32, detail::uint32> mm =
4154 for (
exp += 13; m < 0x80000000 &&
exp; m <<= 1, --
exp)
4156 unsigned int sign = arg.
data_ & 0x8000;
4159 return half(
detail::binary, detail::fixed2half<half::round_style, 31, false, false, true>(m,
exp, sign));
4173 #ifdef HALF_ARITHMETIC_TYPE
4175 detail::float2half<half::round_style>(
std::cosh(detail::half2float<detail::internal_t>(arg.
data_))));
4182 std::pair<detail::uint32, detail::uint32> mm =
4184 detail::uint32 m = mm.first + mm.second, i = (~m & 0xFFFFFFFF) >> 31;
4185 m = (m >> i) | (m & i) | 0x80000000;
4186 if ((
exp += 13 + i) > 29)
4202 #ifdef HALF_ARITHMETIC_TYPE
4204 detail::float2half<half::round_style>(
std::tanh(detail::half2float<detail::internal_t>(arg.
data_))));
4219 i = (~mx & 0xFFFFFFFF) >> 31;
4220 for (
exp = 13; my < 0x80000000; my <<= 1, --
exp)
4222 mx = (mx >> i) | 0x80000000;
4237 #if defined(HALF_ARITHMETIC_TYPE) && HALF_ENABLE_CPP11_CMATH
4239 detail::float2half<half::round_style>(
std::asinh(detail::half2float<detail::internal_t>(arg.
data_))));
4242 if (!
abs ||
abs >= 0x7C00)
4267 #if defined(HALF_ARITHMETIC_TYPE) && HALF_ENABLE_CPP11_CMATH
4269 detail::float2half<half::round_style>(
std::acosh(detail::half2float<detail::internal_t>(arg.
data_))));
4272 if ((arg.
data_ & 0x8000) ||
abs < 0x3C00)
4276 if (arg.
data_ >= 0x7C00)
4293 #if defined(HALF_ARITHMETIC_TYPE) && HALF_ENABLE_CPP11_CMATH
4295 detail::float2half<half::round_style>(
std::atanh(detail::half2float<detail::internal_t>(arg.
data_))));
4308 << ((
abs >> 10) + (
abs <= 0x3FF) + 6),
4309 my = 0x80000000 + m, mx = 0x80000000 - m;
4310 for (; mx < 0x80000000; mx <<= 1, ++
exp)
4312 int i = my >= mx, s;
4314 detail::log2_post<half::round_style, 0xB8AA3B2A>(
4334 #if defined(HALF_ARITHMETIC_TYPE) && HALF_ENABLE_CPP11_CMATH
4336 detail::float2half<half::round_style>(
std::erf(detail::half2float<detail::internal_t>(arg.
data_))));
4338 unsigned int abs = arg.
data_ & 0x7FFF;
4339 if (!
abs ||
abs >= 0x7C00)
4340 return (
abs >= 0x7C00)
4359 #if defined(HALF_ARITHMETIC_TYPE) && HALF_ENABLE_CPP11_CMATH
4361 detail::float2half<half::round_style>(
std::erfc(detail::half2float<detail::internal_t>(arg.
data_))));
4363 unsigned int abs = arg.
data_ & 0x7FFF, sign = arg.
data_ & 0x8000;
4370 detail::binary, detail::rounded<half::round_style, true>((sign >> 1) - (sign >> 15), sign >> 15, 1));
4386 #if defined(HALF_ARITHMETIC_TYPE) && HALF_ENABLE_CPP11_CMATH
4388 detail::float2half<half::round_style>(
std::lgamma(detail::half2float<detail::internal_t>(arg.
data_))));
4393 if (!
abs || arg.
data_ >= 0xE400 || (arg.
data_ >= 0xBC00 && !(
abs & ((1 << (25 - (
abs >> 10))) - 1))))
4395 if (arg.
data_ == 0x3C00 || arg.
data_ == 0x4000)
4412 #if defined(HALF_ARITHMETIC_TYPE) && HALF_ENABLE_CPP11_CMATH
4414 detail::float2half<half::round_style>(
std::tgamma(detail::half2float<detail::internal_t>(arg.
data_))));
4416 unsigned int abs = arg.
data_ & 0x7FFF;
4421 if (arg.
data_ >= 0xE400 || (arg.
data_ >= 0xBC00 && !(
abs & ((1 << (25 - (
abs >> 10))) - 1))))
4423 if (arg.
data_ >= 0xCA80)
4425 detail::binary, detail::underflow<half::round_style>((1 - ((
abs >> (25 - (
abs >> 10))) & 1)) << 15));
4426 if (arg.
data_ <= 0x100 || (arg.
data_ >= 0x4900 && arg.
data_ < 0x8000))
4428 if (arg.
data_ == 0x3C00)
4488 inline long lround(
half arg) {
return detail::half2int<std::round_to_nearest, false, false, long>(arg.
data_); }
4504 inline long lrint(
half arg) {
return detail::half2int<half::round_style, true, true, long>(arg.
data_); }
4515 #if HALF_ENABLE_CPP11_LONG_LONG
4521 inline long long llround(
half arg)
4523 return detail::half2int<std::round_to_nearest, false, false, long long>(arg.
data_);
4532 inline long long llrint(half arg) {
return detail::half2int<half::round_style, true, true, long long>(arg.data_); }
4549 unsigned int abs = arg.
data_ & 0x7FFF;
4550 if (
abs >= 0x7C00 || !
abs)
4554 *
exp += (
abs >> 10) - 14;
4569 unsigned int abs = arg.
data_ & 0x7FFF, sign = arg.
data_ & 0x8000;
4570 if (
abs >= 0x7C00 || !
abs)
4581 unsigned int m = (
abs & 0x3FF) | 0x400;
4583 detail::rounded<half::round_style, false>(
4584 sign | (m >> (1 -
exp)), (m >> -
exp) & 1, (m & ((1 << -
exp) - 1)) != 0));
4617 unsigned int abs = arg.
data_ & 0x7FFF;
4620 return *iptr = arg, arg;
4625 return iptr->
data_ = arg.
data_ & 0x8000, arg;
4626 unsigned int exp =
abs >> 10, mask = (1 << (25 -
exp)) - 1, m = arg.
data_ & mask;
4630 for (; m < 0x400; m <<= 1, --
exp)
4646 if (!
abs ||
abs >= 0x7C00) {
4670 unsigned int value =
static_cast<unsigned>(
exp < 0) << 15;
4673 for (
exp = 18; m < 0x400; m <<= 1, --
exp)
4675 value |= (
exp << 10) + m;
4691 if (
fabs > 0x7C00 || tabs > 0x7C00)
4699 unsigned int out = from.
data_ +
4700 (((from.
data_ >> 15) ^
4701 static_cast<unsigned>((from.
data_ ^ (0x8000 | (0x8000 - (from.
data_ >> 15)))) <
4702 (to.
data_ ^ (0x8000 | (0x8000 - (to.
data_ >> 15))))))
4723 long double lfrom =
static_cast<long double>(from);
4725 return half(
static_cast<float>(to));
4730 unsigned int out = from.
data_ + (((from.
data_ >> 15) ^
static_cast<unsigned>(lfrom < to)) << 1) - 1;
4816 return ((x.
data_ ^ (0x8000 | (0x8000 - (x.
data_ >> 15)))) + (x.
data_ >> 15)) >
4817 ((y.
data_ ^ (0x8000 | (0x8000 - (y.
data_ >> 15)))) + (y.
data_ >> 15)) &&
4827 return ((x.
data_ ^ (0x8000 | (0x8000 - (x.
data_ >> 15)))) + (x.
data_ >> 15)) >=
4828 ((y.
data_ ^ (0x8000 | (0x8000 - (y.
data_ >> 15)))) + (y.
data_ >> 15)) &&
4840 return ((x.
data_ ^ (0x8000 | (0x8000 - (x.
data_ >> 15)))) + (x.
data_ >> 15)) <
4841 ((y.
data_ ^ (0x8000 | (0x8000 - (y.
data_ >> 15)))) + (y.
data_ >> 15)) &&
4853 return ((x.
data_ ^ (0x8000 | (0x8000 - (x.
data_ >> 15)))) + (x.
data_ >> 15)) <=
4854 ((y.
data_ ^ (0x8000 | (0x8000 - (y.
data_ >> 15)))) + (y.
data_ >> 15)) &&
4913 template <
typename T, std::
float_round_style R,
typename U>
T half_cast(
U arg)
5006 throw std::domain_error(msg);
5008 throw std::overflow_error(msg);
5010 throw std::underflow_error(msg);
5012 throw std::range_error(msg);
5017 #undef HALF_UNUSED_NOERR
5018 #undef HALF_CONSTEXPR
5019 #undef HALF_CONSTEXPR_CONST
5020 #undef HALF_CONSTEXPR_NOERR
5021 #undef HALF_NOEXCEPT
5023 #undef HALF_THREAD_LOCAL
5024 #undef HALF_TWOS_COMPLEMENT_INT
5025 #ifdef HALF_POP_WARNINGS
5026 #pragma warning(pop)
5027 #undef HALF_POP_WARNINGS
Half-precision floating-point type.
Definition: half.hpp:2206
friend half asinh(half)
Hyperbolic area sine.
Definition: half.hpp:4235
friend void sincos(half, half *, half *)
Compute sine and cosine simultaneously.
Definition: half.hpp:3799
friend half exp2(half)
Binary exponential.
Definition: half.hpp:3219
half operator++(int)
Postfix increment.
Definition: half.hpp:2311
friend half tanh(half)
Hyperbolic tangent.
Definition: half.hpp:4200
friend std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &, half)
Output operator.
Definition: half.hpp:2912
friend long lrint(half)
Nearest integer using half's internal rounding mode.
Definition: half.hpp:4504
friend half nanh(const char *)
Get NaN value.
Definition: half.hpp:3163
friend half atanh(half)
Hyperbolic area tangent.
Definition: half.hpp:4291
friend half atan(half)
Arc tangent function.
Definition: half.hpp:4039
friend half tan(half)
Tangent function.
Definition: half.hpp:3935
friend half nearbyint(half)
Nearest integer using half's internal rounding mode.
Definition: half.hpp:4511
friend half log1p(half)
Natural logarithm plus one.
Definition: half.hpp:3423
friend half pow(half, half)
Power function.
Definition: half.hpp:3721
half & operator-=(float rhs)
Arithmetic assignment.
Definition: half.hpp:2280
half & operator=(float rhs)
Assignment operator.
Definition: half.hpp:2232
friend half remquo(half, half, int *)
Remainder of division.
Definition: half.hpp:3011
HALF_CONSTEXPR half() HALF_NOEXCEPT
Default constructor.
Definition: half.hpp:2214
half & operator--()
Prefix decrement.
Definition: half.hpp:2306
friend half sqrt(half)
Square root.
Definition: half.hpp:3473
friend half ceil(half)
Nearest integer not less than half value.
Definition: half.hpp:4445
friend half erf(half)
Error function.
Definition: half.hpp:4332
friend half atan2(half, half)
Arc tangent function.
Definition: half.hpp:4073
half & operator/=(float rhs)
Arithmetic assignment.
Definition: half.hpp:2292
friend half modf(half, half *)
Extract integer and fractional parts.
Definition: half.hpp:4615
friend half operator*(half, half)
Multiplication.
Definition: half.hpp:2825
HALF_CONSTEXPR half(detail::binary_t, unsigned int bits) HALF_NOEXCEPT
Constructor.
Definition: half.hpp:2335
friend half sin(half)
Sine function.
Definition: half.hpp:3868
friend half trunc(half)
Nearest integer not greater in magnitude than half value.
Definition: half.hpp:4467
friend half nexttoward(half, long double)
Next representable value.
Definition: half.hpp:4718
friend half lgamma(half)
Natural logarithm of gamma function.
Definition: half.hpp:4384
friend HALF_CONSTEXPR bool isgreaterequal(half, half)
Quiet comparison for greater equal.
Definition: half.hpp:4825
friend half nextafter(half, half)
Next representable value.
Definition: half.hpp:4688
friend HALF_CONSTEXPR half copysign(half, half)
Take sign.
Definition: half.hpp:4741
friend half operator/(half, half)
Division.
Definition: half.hpp:2865
friend half tgamma(half)
Gamma function.
Definition: half.hpp:4410
half & operator/=(half rhs)
Arithmetic assignment.
Definition: half.hpp:2268
friend half exp(half)
Exponential function.
Definition: half.hpp:3184
friend HALF_CONSTEXPR half operator-(half)
Negation.
Definition: half.hpp:2740
friend half log10(half)
Common logarithm.
Definition: half.hpp:3332
friend HALF_CONSTEXPR bool isnan(half)
Check for NaN.
Definition: half.hpp:4787
friend half scalbln(half, long)
Multiply by power of two.
Definition: half.hpp:4567
friend half frexp(half, int *)
Decompress floating-point number.
Definition: half.hpp:4546
friend half cbrt(half)
Cubic root.
Definition: half.hpp:3546
friend half log(half)
Natural logarithm.
Definition: half.hpp:3301
friend HALF_CONSTEXPR half fabs(half)
Absolute value.
Definition: half.hpp:2952
friend HALF_CONSTEXPR bool islessgreater(half, half)
Quiet comarison for less or greater.
Definition: half.hpp:4864
friend HALF_CONSTEXPR bool isnormal(half)
Check if normal number.
Definition: half.hpp:4794
friend half fdim(half, half)
Positive difference.
Definition: half.hpp:3150
friend HALF_CONSTEXPR int fpclassify(half)
Classify floating-point value.
Definition: half.hpp:4759
half & operator*=(half rhs)
Arithmetic assignment.
Definition: half.hpp:2261
friend HALF_CONSTEXPR_NOERR bool operator==(half, half)
Comparison for equality.
Definition: half.hpp:2659
friend half cos(half)
Cosine function.
Definition: half.hpp:3905
detail::uint16 data_
Internal binary representation.
Definition: half.hpp:2338
half & operator+=(float rhs)
Arithmetic assignment.
Definition: half.hpp:2274
half & operator+=(half rhs)
Arithmetic assignment.
Definition: half.hpp:2247
friend HALF_CONSTEXPR bool isfinite(half)
Check if finite number.
Definition: half.hpp:4773
friend half rsqrt(half)
Inverse square root.
Definition: half.hpp:3500
friend HALF_CONSTEXPR bool isgreater(half, half)
Quiet comparison for greater than.
Definition: half.hpp:4814
friend half fmod(half, half)
Remainder of division.
Definition: half.hpp:2966
half(float rhs)
Conversion constructor.
Definition: half.hpp:2219
friend HALF_CONSTEXPR bool signbit(half)
Check sign.
Definition: half.hpp:4801
friend half acos(half)
Arc cosine function.
Definition: half.hpp:4009
half & operator*=(float rhs)
Arithmetic assignment.
Definition: half.hpp:2286
friend half remainder(half, half)
Remainder of division.
Definition: half.hpp:2989
friend half cosh(half)
Hyperbolic cosine.
Definition: half.hpp:4171
friend HALF_CONSTEXPR_NOERR half fmax(half, half)
Maximum of half expressions.
Definition: half.hpp:3116
friend long lround(half)
Nearest integer.
Definition: half.hpp:4488
friend HALF_CONSTEXPR_NOERR bool operator<=(half, half)
Comparison for less equal.
Definition: half.hpp:2707
friend std::basic_istream< charT, traits > & operator>>(std::basic_istream< charT, traits > &, half &)
Input operator.
Definition: half.hpp:2931
friend half acosh(half)
Hyperbolic area cosine.
Definition: half.hpp:4265
friend half log2(half)
Binary logarithm.
Definition: half.hpp:3373
friend half round(half)
Nearest integer.
Definition: half.hpp:4478
friend HALF_CONSTEXPR bool isless(half, half)
Quiet comparison for less than.
Definition: half.hpp:4838
friend half expm1(half)
Exponential minus one.
Definition: half.hpp:3248
friend HALF_CONSTEXPR_NOERR bool operator>=(half, half)
Comparison for greater equal.
Definition: half.hpp:2720
friend half hypot(half, half)
Hypotenuse function.
Definition: half.hpp:3600
half & operator-=(half rhs)
Arithmetic assignment.
Definition: half.hpp:2254
friend HALF_CONSTEXPR_NOERR bool operator!=(half, half)
Comparison for inequality.
Definition: half.hpp:2670
half & operator++()
Prefix increment.
Definition: half.hpp:2301
friend HALF_CONSTEXPR_NOERR bool operator<(half, half)
Comparison for less than.
Definition: half.hpp:2681
friend half erfc(half)
Complementary error function.
Definition: half.hpp:4357
friend half operator+(half, half)
Addition.
Definition: half.hpp:2749
friend half floor(half)
Nearest integer not greater than half value.
Definition: half.hpp:4456
friend HALF_CONSTEXPR_NOERR half fmin(half, half)
Minimum of half expressions.
Definition: half.hpp:3132
half operator--(int)
Postfix decrement.
Definition: half.hpp:2321
friend HALF_CONSTEXPR bool isinf(half)
Check for infinity.
Definition: half.hpp:4780
friend int ilogb(half)
Extract exponent.
Definition: half.hpp:4643
friend half fma(half, half, half)
Fused multiply add.
Definition: half.hpp:3038
friend half sinh(half)
Hyperbolic sine.
Definition: half.hpp:4140
friend half rint(half)
Nearest integer using half's internal rounding mode.
Definition: half.hpp:4496
friend HALF_CONSTEXPR bool islessequal(half, half)
Quiet comparison for less equal.
Definition: half.hpp:4851
friend half asin(half)
Arc sine.
Definition: half.hpp:3977
friend half logb(half)
Extract exponent.
Definition: half.hpp:4661
static const std::float_round_style round_style
Rounding mode to use.
Definition: half.hpp:2331
friend HALF_CONSTEXPR_NOERR bool operator>(half, half)
Comparison for greater than.
Definition: half.hpp:2694
static HALF_CONSTEXPR half_float::half max() HALF_NOTHROW
Largest finite value.
Definition: half.hpp:2583
static HALF_CONSTEXPR half_float::half quiet_NaN() HALF_NOTHROW
Quiet NaN.
Definition: half.hpp:2607
static HALF_CONSTEXPR half_float::half min() HALF_NOTHROW
Smallest positive normal value.
Definition: half.hpp:2571
static HALF_CONSTEXPR half_float::half round_error() HALF_NOTHROW
Maximum rounding error in ULP (units in the last place).
Definition: half.hpp:2595
static HALF_CONSTEXPR half_float::half infinity() HALF_NOTHROW
Positive infinity.
Definition: half.hpp:2601
static HALF_CONSTEXPR half_float::half epsilon() HALF_NOTHROW
Difference between 1 and next representable value.
Definition: half.hpp:2589
static HALF_CONSTEXPR half_float::half lowest() HALF_NOTHROW
Smallest finite value.
Definition: half.hpp:2577
static HALF_CONSTEXPR half_float::half signaling_NaN() HALF_NOTHROW
Signaling NaN.
Definition: half.hpp:2613
static HALF_CONSTEXPR half_float::half denorm_min() HALF_NOTHROW
Smallest positive subnormal value.
Definition: half.hpp:2619
#define FP_ILOGBNAN
Definition: half.hpp:415
#define HALF_NOEXCEPT
Definition: half.hpp:237
#define FP_NAN
Definition: half.hpp:424
#define HALF_CONSTEXPR_NOERR
Definition: half.hpp:229
#define FP_ZERO
Definition: half.hpp:421
#define FP_INFINITE
Definition: half.hpp:427
#define FE_UNDERFLOW
Definition: half.hpp:437
#define HALF_CONSTEXPR_CONST
Definition: half.hpp:228
#define FE_INVALID
Definition: half.hpp:434
#define FE_INEXACT
Definition: half.hpp:438
#define HALF_THREAD_LOCAL
Definition: half.hpp:245
#define HALF_NOTHROW
Definition: half.hpp:238
#define FP_ILOGB0
Definition: half.hpp:412
#define HALF_UNUSED_NOERR(name)
Definition: half.hpp:214
#define FE_DIVBYZERO
Definition: half.hpp:435
#define FP_NORMAL
Definition: half.hpp:430
#define HALF_CONSTEXPR
Definition: half.hpp:227
#define FE_OVERFLOW
Definition: half.hpp:436
#define FP_SUBNORMAL
Definition: half.hpp:418
#define HALF_ROUND_STYLE
Default rounding mode.
Definition: half.hpp:387
#define HALF_ERRHANDLING_UNDERFLOW_TO_INEXACT
Raise INEXACT exception on underflow.
Definition: half.hpp:363
bool_type< false > false_type
Definition: half.hpp:485
HALF_CONSTEXPR_CONST binary_t binary
Tag for binary construction.
Definition: half.hpp:560
std::pair< uint32, uint32 > hyperbolic_args(unsigned int abs, int &exp, unsigned int n=32)
Get exponentials for hyperbolic computation.
Definition: half.hpp:1810
unsigned int integral(unsigned int value)
Round half-precision number to nearest integer value.
Definition: half.hpp:882
uint32 exp2(uint32 m, unsigned int n=32)
Fixed point binary exponential.
Definition: half.hpp:1660
bool builtin_signbit(T arg)
Check sign.
Definition: half.hpp:602
unsigned int hypot_post(uint32 r, int exp)
Hypotenuse square root and postprocessing.
Definition: half.hpp:1902
int & errflags()
Internal exception flags.
Definition: half.hpp:645
bool builtin_isnan(T arg)
Check for NaN.
Definition: half.hpp:586
unsigned short uint16
Unsigned integer of (at least) 16 bits width.
Definition: half.hpp:526
std::pair< uint32, uint32 > atan2_args(unsigned int abs)
Get arguments for atan2 function.
Definition: half.hpp:1782
HALF_CONSTEXPR_NOERR unsigned int check_underflow(unsigned int arg)
Check value for underflow.
Definition: half.hpp:798
unsigned int fixed2half(uint32 m, int exp=14, unsigned int sign=0, int s=0)
Convert fixed point to half-precision floating-point.
Definition: half.hpp:920
unsigned int mod(unsigned int x, unsigned int y, int *quo=NULL)
Half precision positive modulus.
Definition: half.hpp:1573
uint32 sqrt(uint32 &r, int &exp)
Fixed point square root.
Definition: half.hpp:1638
HALF_CONSTEXPR_NOERR unsigned int select(unsigned int x, unsigned int HALF_UNUSED_NOERR(y))
Select value or signaling NaN.
Definition: half.hpp:762
float half2float_impl(unsigned int value, float, true_type)
Convert half-precision to IEEE single-precision.
Definition: half.hpp:1148
HALF_CONSTEXPR_NOERR unsigned int overflow(unsigned int sign=0)
Half-precision overflow.
Definition: half.hpp:815
uint32 multiply64(uint32 x, uint32 y)
64-bit multiplication.
Definition: half.hpp:1531
T half2int(unsigned int value)
Convert half-precision floating-point to integer.
Definition: half.hpp:1476
uint32 mulhi(uint32 x, uint32 y)
upper part of 64-bit multiplication.
Definition: half.hpp:1517
bool_type< true > true_type
Definition: half.hpp:484
HALF_CONSTEXPR_NOERR bool compsignal(unsigned int x, unsigned int y)
Check and signal for any NaN.
Definition: half.hpp:708
uint32 atan2(uint32 my, uint32 mx, unsigned int n=31)
Fixed point arc tangent.
Definition: half.hpp:1732
long int32
Fastest unsigned integer of (at least) 32 bits width.
Definition: half.hpp:532
unsigned int float2half(T value)
Convert floating-point to half-precision.
Definition: half.hpp:1112
HALF_CONSTEXPR_NOERR unsigned int underflow(unsigned int sign=0)
Half-precision underflow.
Definition: half.hpp:831
HALF_CONSTEXPR_NOERR unsigned int signal(unsigned int nan)
Signal and silence signaling NaN.
Definition: half.hpp:720
HALF_CONSTEXPR_NOERR unsigned int invalid()
Raise domain error and return NaN.
Definition: half.hpp:774
unsigned int gamma(unsigned int arg)
Gamma function and postprocessing.
Definition: half.hpp:2101
std::pair< uint32, uint32 > sincos(uint32 mz, unsigned int n=31)
Fixed point sine and cosine.
Definition: half.hpp:1708
uint32 arithmetic_shift(uint32 arg, int i)
Platform-independent arithmetic right shift.
Definition: half.hpp:629
uint32 log2(uint32 m, unsigned int n=32)
Fixed point binary logarithm.
Definition: half.hpp:1684
T half2float(unsigned int value)
Convert half-precision to floating-point.
Definition: half.hpp:1463
uint32 divide64(uint32 x, uint32 y, int &s)
64-bit division.
Definition: half.hpp:1546
void raise(int HALF_UNUSED_NOERR(flags), bool HALF_UNUSED_NOERR(cond)=true)
Raise floating-point exception.
Definition: half.hpp:654
uint32 angle_arg(unsigned int abs, int &k)
Reduce argument for trigonometric functions.
Definition: half.hpp:1754
unsigned int log2_post(uint32 m, int ilog, int exp, unsigned int sign=0)
Postprocessing for binary logarithm.
Definition: half.hpp:1876
unsigned int area(unsigned int arg)
Area function and postprocessing.
Definition: half.hpp:1945
HALF_CONSTEXPR_NOERR unsigned int rounded(unsigned int value, int g, int s)
Round half-precision number.
Definition: half.hpp:852
unsigned long uint32
Fastest unsigned integer of (at least) 32 bits width.
Definition: half.hpp:529
unsigned int float2half_impl(float value, true_type)
Convert IEEE single-precision to half-precision.
Definition: half.hpp:945
uint32 sign_mask(uint32 arg)
Platform-independent sign mask.
Definition: half.hpp:615
bool builtin_isinf(T arg)
Check for infinity.
Definition: half.hpp:570
unsigned int erf(unsigned int arg)
Error function and postprocessing.
Definition: half.hpp:2076
unsigned int int2half(T value)
Convert integer to half-precision floating-point.
Definition: half.hpp:1125
unsigned int tangent_post(uint32 my, uint32 mx, int exp, unsigned int sign=0)
Division and postprocessing for tangents.
Definition: half.hpp:1924
unsigned int exp2_post(uint32 m, int exp, bool esign, unsigned int sign=0, unsigned int n=32)
Postprocessing for binary exponential.
Definition: half.hpp:1845
HALF_CONSTEXPR_NOERR unsigned int pole(unsigned int sign=0)
Raise pole error and return infinity.
Definition: half.hpp:786
Main namespace for half-precision functionality.
Definition: half.hpp:444
half asinh(half arg)
Hyperbolic area sine.
Definition: half.hpp:4235
half sinh(half arg)
Hyperbolic sine.
Definition: half.hpp:4140
int feclearexcept(int excepts)
Clear exception flags.
Definition: half.hpp:4931
HALF_CONSTEXPR half fabs(half arg)
Absolute value.
Definition: half.hpp:2952
half nextafter(half from, half to)
Next representable value.
Definition: half.hpp:4688
half atan(half arg)
Arc tangent function.
Definition: half.hpp:4039
half hypot(half x, half y)
Hypotenuse function.
Definition: half.hpp:3600
HALF_CONSTEXPR bool isunordered(half x, half y)
Quiet check if unordered.
Definition: half.hpp:4875
half fdim(half x, half y)
Positive difference.
Definition: half.hpp:3150
half remquo(half x, half y, int *quo)
Remainder of division.
Definition: half.hpp:3011
int fegetexceptflag(int *flagp, int excepts)
Save exception flags.
Definition: half.hpp:4970
int ilogb(half arg)
Extract exponent.
Definition: half.hpp:4643
half lgamma(half arg)
Natural logarithm of gamma function.
Definition: half.hpp:4384
HALF_CONSTEXPR half copysign(half x, half y)
Take sign.
Definition: half.hpp:4741
HALF_CONSTEXPR bool isfinite(half arg)
Check if finite number.
Definition: half.hpp:4773
int fesetexceptflag(const int *flagp, int excepts)
Restore exception flags.
Definition: half.hpp:4985
HALF_CONSTEXPR half abs(half arg)
Absolute value.
Definition: half.hpp:2958
half fma(half x, half y, half z)
Fused multiply add.
Definition: half.hpp:3038
HALF_CONSTEXPR_NOERR half fmin(half x, half y)
Minimum of half expressions.
Definition: half.hpp:3132
half nearbyint(half arg)
Nearest integer using half's internal rounding mode.
Definition: half.hpp:4511
half expm1(half arg)
Exponential minus one.
Definition: half.hpp:3248
half ldexp(half arg, int exp)
Multiply by power of two.
Definition: half.hpp:4607
half sin(half arg)
Sine function.
Definition: half.hpp:3868
half tanh(half arg)
Hyperbolic tangent.
Definition: half.hpp:4200
std::basic_istream< charT, traits > & operator>>(std::basic_istream< charT, traits > &in, half &arg)
Input operator.
Definition: half.hpp:2931
half rint(half arg)
Nearest integer using half's internal rounding mode.
Definition: half.hpp:4496
HALF_CONSTEXPR_NOERR bool operator!=(half x, half y)
Comparison for inequality.
Definition: half.hpp:2670
HALF_CONSTEXPR_NOERR half fmax(half x, half y)
Maximum of half expressions.
Definition: half.hpp:3116
HALF_CONSTEXPR_NOERR bool operator<(half x, half y)
Comparison for less than.
Definition: half.hpp:2681
HALF_CONSTEXPR half operator-(half arg)
Negation.
Definition: half.hpp:2740
T half_cast(U arg)
Cast to or from half-precision floating-point number.
Definition: half.hpp:4896
half fmod(half x, half y)
Remainder of division.
Definition: half.hpp:2966
half log(half arg)
Natural logarithm.
Definition: half.hpp:3301
half cos(half arg)
Cosine function.
Definition: half.hpp:3905
half scalbn(half arg, int exp)
Multiply by power of two.
Definition: half.hpp:4596
half exp2(half arg)
Binary exponential.
Definition: half.hpp:3219
HALF_CONSTEXPR int fpclassify(half arg)
Classify floating-point value.
Definition: half.hpp:4759
HALF_CONSTEXPR_NOERR bool operator>=(half x, half y)
Comparison for greater equal.
Definition: half.hpp:2720
half atanh(half arg)
Hyperbolic area tangent.
Definition: half.hpp:4291
half nexttoward(half from, long double to)
Next representable value.
Definition: half.hpp:4718
half round(half arg)
Nearest integer.
Definition: half.hpp:4478
half log2(half arg)
Binary logarithm.
Definition: half.hpp:3373
HALF_CONSTEXPR bool isgreater(half x, half y)
Quiet comparison for greater than.
Definition: half.hpp:4814
half asin(half arg)
Arc sine.
Definition: half.hpp:3977
half sqrt(half arg)
Square root.
Definition: half.hpp:3473
half trunc(half arg)
Nearest integer not greater in magnitude than half value.
Definition: half.hpp:4467
half erfc(half arg)
Complementary error function.
Definition: half.hpp:4357
half tan(half arg)
Tangent function.
Definition: half.hpp:3935
HALF_CONSTEXPR half operator+(half arg)
Identity.
Definition: half.hpp:2735
half log10(half arg)
Common logarithm.
Definition: half.hpp:3332
half rsqrt(half arg)
Inverse square root.
Definition: half.hpp:3500
HALF_CONSTEXPR bool signbit(half arg)
Check sign.
Definition: half.hpp:4801
half floor(half arg)
Nearest integer not greater than half value.
Definition: half.hpp:4456
half acosh(half arg)
Hyperbolic area cosine.
Definition: half.hpp:4265
HALF_CONSTEXPR bool isnan(half arg)
Check for NaN.
Definition: half.hpp:4787
HALF_CONSTEXPR_NOERR bool operator<=(half x, half y)
Comparison for less equal.
Definition: half.hpp:2707
half operator*(half x, half y)
Multiplication.
Definition: half.hpp:2825
HALF_CONSTEXPR bool isnormal(half arg)
Check if normal number.
Definition: half.hpp:4794
std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &out, half arg)
Output operator.
Definition: half.hpp:2912
half atan2(half y, half x)
Arc tangent function.
Definition: half.hpp:4073
int feraiseexcept(int excepts)
Raise exception flags.
Definition: half.hpp:4955
HALF_CONSTEXPR bool isless(half x, half y)
Quiet comparison for less than.
Definition: half.hpp:4838
half scalbln(half arg, long exp)
Multiply by power of two.
Definition: half.hpp:4567
half tgamma(half arg)
Gamma function.
Definition: half.hpp:4410
HALF_CONSTEXPR_NOERR bool operator==(half x, half y)
Comparison for equality.
Definition: half.hpp:2659
long lrint(half arg)
Nearest integer using half's internal rounding mode.
Definition: half.hpp:4504
HALF_CONSTEXPR bool isinf(half arg)
Check for infinity.
Definition: half.hpp:4780
HALF_CONSTEXPR_NOERR bool operator>(half x, half y)
Comparison for greater than.
Definition: half.hpp:2694
half cosh(half arg)
Hyperbolic cosine.
Definition: half.hpp:4171
half logb(half arg)
Extract exponent.
Definition: half.hpp:4661
half erf(half arg)
Error function.
Definition: half.hpp:4332
void sincos(half arg, half *sin, half *cos)
Compute sine and cosine simultaneously.
Definition: half.hpp:3799
half ceil(half arg)
Nearest integer not less than half value.
Definition: half.hpp:4445
half frexp(half arg, int *exp)
Decompress floating-point number.
Definition: half.hpp:4546
half log1p(half arg)
Natural logarithm plus one.
Definition: half.hpp:3423
HALF_CONSTEXPR bool islessgreater(half x, half y)
Quiet comarison for less or greater.
Definition: half.hpp:4864
half hypot(half x, half y, half z)
Hypotenuse function.
Definition: half.hpp:3651
long lround(half arg)
Nearest integer.
Definition: half.hpp:4488
half acos(half arg)
Arc cosine function.
Definition: half.hpp:4009
HALF_CONSTEXPR bool islessequal(half x, half y)
Quiet comparison for less equal.
Definition: half.hpp:4851
half pow(half x, half y)
Power function.
Definition: half.hpp:3721
half nanh(const char *arg)
Get NaN value.
Definition: half.hpp:3163
half modf(half arg, half *iptr)
Extract integer and fractional parts.
Definition: half.hpp:4615
half cbrt(half arg)
Cubic root.
Definition: half.hpp:3546
void fethrowexcept(int excepts, const char *msg="")
Throw C++ exceptions based on set exception flags.
Definition: half.hpp:5002
HALF_CONSTEXPR bool isgreaterequal(half x, half y)
Quiet comparison for greater equal.
Definition: half.hpp:4825
int fetestexcept(int excepts)
Test exception flags.
Definition: half.hpp:4944
half exp(half arg)
Exponential function.
Definition: half.hpp:3184
half remainder(half x, half y)
Remainder of division.
Definition: half.hpp:2989
half operator/(half x, half y)
Division.
Definition: half.hpp:2865
Extensions to the C++ standard library.
Definition: big_integer.hpp:576
MICROSOFT_QUANTUM_DECL void T(_In_ uintq sid, _In_ uintq q)
(External API) "T" Gate
Definition: pinvoke_api.cpp:1658
MICROSOFT_QUANTUM_DECL void R(_In_ uintq sid, _In_ uintq b, _In_ double phi, _In_ uintq q)
(External API) Rotation around Pauli axes
Definition: pinvoke_api.cpp:2146
MICROSOFT_QUANTUM_DECL void S(_In_ uintq sid, _In_ uintq q)
(External API) "S" Gate
Definition: pinvoke_api.cpp:1616
MICROSOFT_QUANTUM_DECL void U(_In_ uintq sid, _In_ uintq q, _In_ double theta, _In_ double phi, _In_ double lambda)
(External API) 3-parameter unitary gate
Definition: pinvoke_api.cpp:1728
Tag type for binary construction.
Definition: half.hpp:557
unsigned long type
Definition: half.hpp:546
Type traits for floating-point bits.
Definition: half.hpp:498
unsigned char type
Definition: half.hpp:499
Helper for tag dispatching.
Definition: half.hpp:483
F type
Definition: half.hpp:479
Conditional type.
Definition: half.hpp:475
T type
Definition: half.hpp:476
Class for 1.31 unsigned floating-point computation.
Definition: half.hpp:1990
friend f31 operator-(f31 a, f31 b)
Subtraction operator.
Definition: half.hpp:2029
int exp
exponent.
Definition: half.hpp:2063
friend f31 operator*(f31 a, f31 b)
Multiplication operator.
Definition: half.hpp:2044
friend f31 operator/(f31 a, f31 b)
Division operator.
Definition: half.hpp:2055
friend f31 operator+(f31 a, f31 b)
Addition operator.
Definition: half.hpp:2015
f31(unsigned int abs)
Constructor.
Definition: half.hpp:2002
HALF_CONSTEXPR f31(uint32 mant, int e)
Constructor.
Definition: half.hpp:1994
uint32 m
mantissa as 1.31.
Definition: half.hpp:2062
static T cast_impl(half arg, true_type)
Definition: half.hpp:2482
static T cast(half arg)
Definition: half.hpp:2479
static T cast_impl(half arg, false_type)
Definition: half.hpp:2483
static half cast_impl(U arg, false_type)
Definition: half.hpp:2472
static half cast(U arg)
Definition: half.hpp:2468
static half cast_impl(U arg, true_type)
Definition: half.hpp:2471
static half cast(half arg)
Definition: half.hpp:2486
Helper class for half casts.
Definition: half.hpp:2462
Type traits for floating-point types.
Definition: half.hpp:488