MU Library
half_float::detail Namespace Reference

Classes

struct  conditional
 Conditional type. More...
 
struct  conditional< false, T, F >
 
struct  bool_type
 Helper for tag dispatching. More...
 
struct  is_float
 Type traits for floating-point types. More...
 
struct  is_float< const T >
 
struct  is_float< volatile T >
 
struct  is_float< const volatile T >
 
struct  is_float< float >
 
struct  is_float< double >
 
struct  is_float< long double >
 
struct  bits
 Type traits for floating-point bits. More...
 
struct  bits< const T >
 
struct  bits< volatile T >
 
struct  bits< const volatile T >
 
struct  bits< float >
 Unsigned integer of (at least) 32 bits width. More...
 
struct  bits< double >
 Unsigned integer of (at least) 64 bits width. More...
 
struct  binary_t
 Tag type for binary construction. More...
 
struct  f31
 Class for 1.31 unsigned floating-point computation. More...
 
struct  half_caster
 
struct  half_caster< half, U, R >
 
struct  half_caster< T, half, R >
 
struct  half_caster< half, half, R >
 

Typedefs

typedef bool_type< true > true_type
 
typedef bool_type< false > false_type
 
typedef unsigned short uint16
 Unsigned integer of (at least) 16 bits width. More...
 
typedef unsigned long uint32
 Fastest unsigned integer of (at least) 32 bits width. More...
 
typedef long int32
 Fastest unsigned integer of (at least) 32 bits width. More...
 

Functions

Implementation defined classification and arithmetic
template<typename T >
bool builtin_isinf (T arg)
 
template<typename T >
bool builtin_isnan (T arg)
 
template<typename T >
bool builtin_signbit (T arg)
 
uint32 sign_mask (uint32 arg)
 
uint32 arithmetic_shift (uint32 arg, int i)
 
Error handling
int & errflags ()
 
void raise (int HALF_UNUSED_NOERR(flags), bool HALF_UNUSED_NOERR(cond)=true)
 
HALF_CONSTEXPR_NOERR bool compsignal (unsigned int x, unsigned int y)
 
HALF_CONSTEXPR_NOERR unsigned int signal (unsigned int nan)
 
HALF_CONSTEXPR_NOERR unsigned int signal (unsigned int x, unsigned int y)
 
HALF_CONSTEXPR_NOERR unsigned int signal (unsigned int x, unsigned int y, unsigned int z)
 
HALF_CONSTEXPR_NOERR unsigned int select (unsigned int x, unsigned int HALF_UNUSED_NOERR(y))
 
HALF_CONSTEXPR_NOERR unsigned int invalid ()
 
HALF_CONSTEXPR_NOERR unsigned int pole (unsigned int sign=0)
 
HALF_CONSTEXPR_NOERR unsigned int check_underflow (unsigned int arg)
 
Conversion and rounding
template<std::float_round_style R>
HALF_CONSTEXPR_NOERR unsigned int overflow (unsigned int sign=0)
 
template<std::float_round_style R>
HALF_CONSTEXPR_NOERR unsigned int underflow (unsigned int sign=0)
 
template<std::float_round_style R, bool I>
HALF_CONSTEXPR_NOERR unsigned int rounded (unsigned int value, int g, int s)
 
template<std::float_round_style R, bool E, bool I>
unsigned int integral (unsigned int value)
 
template<std::float_round_style R, unsigned int F, bool S, bool N, bool I>
unsigned int fixed2half (uint32 m, int exp=14, unsigned int sign=0, int s=0)
 
template<std::float_round_style R>
unsigned int float2half_impl (float value, true_type)
 
template<std::float_round_style R>
unsigned int float2half_impl (double value, true_type)
 
template<std::float_round_style R, typename T >
unsigned int float2half_impl (T value,...)
 
template<std::float_round_style R, typename T >
unsigned int float2half (T value)
 
template<std::float_round_style R, typename T >
unsigned int int2half (T value)
 
float half2float_impl (unsigned int value, float, true_type)
 
double half2float_impl (unsigned int value, double, true_type)
 
template<typename T >
half2float_impl (unsigned int value, T,...)
 
template<typename T >
half2float (unsigned int value)
 
template<std::float_round_style R, bool E, bool I, typename T >
half2int (unsigned int value)
 
Mathematics
template<std::float_round_style R>
uint32 mulhi (uint32 x, uint32 y)
 
uint32 multiply64 (uint32 x, uint32 y)
 
uint32 divide64 (uint32 x, uint32 y, int &s)
 
template<bool Q, bool R>
unsigned int mod (unsigned int x, unsigned int y, int *quo=NULL)
 
template<unsigned int F>
uint32 sqrt (uint32 &r, int &exp)
 
uint32 exp2 (uint32 m, unsigned int n=32)
 
uint32 log2 (uint32 m, unsigned int n=32)
 
std::pair< uint32, uint32sincos (uint32 mz, unsigned int n=31)
 
uint32 atan2 (uint32 my, uint32 mx, unsigned int n=31)
 
uint32 angle_arg (unsigned int abs, int &k)
 
std::pair< uint32, uint32atan2_args (unsigned int abs)
 
std::pair< uint32, uint32hyperbolic_args (unsigned int abs, int &exp, unsigned int n=32)
 
template<std::float_round_style R>
unsigned int exp2_post (uint32 m, int exp, bool esign, unsigned int sign=0, unsigned int n=32)
 
template<std::float_round_style R, uint32 L>
unsigned int log2_post (uint32 m, int ilog, int exp, unsigned int sign=0)
 
template<std::float_round_style R>
unsigned int hypot_post (uint32 r, int exp)
 
template<std::float_round_style R>
unsigned int tangent_post (uint32 my, uint32 mx, int exp, unsigned int sign=0)
 
template<std::float_round_style R, bool S>
unsigned int area (unsigned int arg)
 
template<std::float_round_style R, bool C>
unsigned int erf (unsigned int arg)
 
template<std::float_round_style R, bool L>
unsigned int gamma (unsigned int arg)
 

Variables

HALF_CONSTEXPR_CONST binary_t binary = binary_t()
 Tag for binary construction. More...
 

Typedef Documentation

◆ false_type

Definition at line 516 of file half.hpp.

◆ int32

Fastest unsigned integer of (at least) 32 bits width.

Definition at line 599 of file half.hpp.

◆ true_type

Definition at line 515 of file half.hpp.

◆ uint16

typedef unsigned short half_float::detail::uint16

Unsigned integer of (at least) 16 bits width.

Definition at line 593 of file half.hpp.

◆ uint32

typedef unsigned long half_float::detail::uint32

Fastest unsigned integer of (at least) 32 bits width.

Definition at line 596 of file half.hpp.

Function Documentation

◆ angle_arg()

uint32 half_float::detail::angle_arg ( unsigned int  abs,
int &  k 
)
inline

Reduce argument for trigonometric functions.

Parameters
abshalf-precision floating-point value
kvalue to take quarter period
Returns
abs reduced to [-pi/4,pi/4] as Q0.30

Definition at line 4617 of file half.hpp.

4617 {
4618  uint32 m = (abs & 0x3FF) | ((abs > 0x3FF) << 10);
4619  int exp = (abs >> 10) + (abs <= 0x3FF) - 15;
4620  if (abs < 0x3A48)
4621  return k = 0, m << (exp + 20);
4622 #if HALF_ENABLE_CPP11_LONG_LONG
4623  unsigned long long y = m * 0xA2F9836E4E442, mask = (1ULL << (62 - exp)) - 1, yi = (y + (mask >> 1)) & ~mask, f = y - yi;
4624  uint32 sign = -static_cast<uint32>(f >> 63);
4625  k = static_cast<int>(yi >> (62 - exp));
4626  return (multiply64(static_cast<uint32>((sign ? -f : f) >> (31 - exp)), 0xC90FDAA2) ^ sign) - sign;
4627 #else
4628  uint32 yh = m * 0xA2F98 + mulhi<std::round_toward_zero>(m, 0x36E4E442), yl = (m * 0x36E4E442) & 0xFFFFFFFF;
4629  uint32 mask = (static_cast<uint32>(1) << (30 - exp)) - 1, yi = (yh + (mask >> 1)) & ~mask, sign = -static_cast<uint32>(yi > yh);
4630  k = static_cast<int>(yi >> (30 - exp));
4631  uint32 fh = (yh ^ sign) + (yi ^ ~sign) - ~sign, fl = (yl ^ sign) - sign;
4632  return (multiply64((exp > -1) ? (((fh << (1 + exp)) & 0xFFFFFFFF) | ((fl & 0xFFFFFFFF) >> (31 - exp))) : fh, 0xC90FDAA2) ^ sign) - sign;
4633 #endif
4634 }
4635 
uint32 multiply64(uint32 x, uint32 y)
Definition: half.hpp:4259
unsigned long uint32
Fastest unsigned integer of (at least) 32 bits width.
Definition: half.hpp:596
HALF_CONSTEXPR half abs(half arg)
Definition: half.hpp:5905
half exp(half arg)
Definition: half.hpp:6111

◆ area()

template<std::float_round_style R, bool S>
unsigned int half_float::detail::area ( unsigned int  arg)

Area function and postprocessing. This computes the value directly in Q2.30 using the representation asinh|acosh(x) = log(x+sqrt(x^2+|-1)).

Template Parameters
Rrounding mode to use
Strue for asinh, false for acosh
Parameters
arghalf-precision argument
Returns
asinh|acosh(arg) converted to half-precision
Exceptions
MU_HALF_FE_OVERFLOWon overflows
MU_HALF_FE_UNDERFLOWon underflows
MU_HALF_FE_INEXACTif no other exception occurred

Definition at line 4809 of file half.hpp.

4809 {
4810  int abs = arg & 0x7FFF, expx = (abs >> 10) + (abs <= 0x3FF) - 15, expy = -15, ilog, i;
4811  uint32 mx = static_cast<uint32>((abs & 0x3FF) | ((abs > 0x3FF) << 10)) << 20, my, r;
4812  for (; abs < 0x400; abs <<= 1, --expy)
4813  ;
4814  expy += abs >> 10;
4815  r = ((abs & 0x3FF) | 0x400) << 5;
4816  r *= r;
4817  i = r >> 31;
4818  expy = 2 * expy + i;
4819  r >>= i;
4820  if (S)
4821  {
4822  if (expy < 0)
4823  {
4824  r = 0x40000000 + ((expy > -30) ? ((r >> -expy) | ((r & ((static_cast<uint32>(1) << -expy) - 1)) != 0)) : 1);
4825  expy = 0;
4826  }
4827  else
4828  {
4829  r += 0x40000000 >> expy;
4830  i = r >> 31;
4831  r = (r >> i) | (r & i);
4832  expy += i;
4833  }
4834  }
4835  else
4836  {
4837  r -= 0x40000000 >> expy;
4838  for (; r < 0x40000000; r <<= 1, --expy)
4839  ;
4840  }
4841  my = sqrt<30>(r, expy);
4842  my = (my << 15) + (r << 14) / my;
4843  if (S)
4844  {
4845  mx >>= expy - expx;
4846  ilog = expy;
4847  }
4848  else
4849  {
4850  my >>= expx - expy;
4851  ilog = expx;
4852  }
4853  my += mx;
4854  i = my >> 31;
4855  static const int G = S && (R == std::round_to_nearest);
4856  return log2_post<R, 0xB8AA3B2A>(log2(my >> i, 26 + S + G) + (G << 3), ilog + i, 17, arg & (static_cast<unsigned>(S) << 15));
4857 }
4858 
half log2(half arg)
Definition: half.hpp:6292

◆ arithmetic_shift()

uint32 half_float::detail::arithmetic_shift ( uint32  arg,
int  i 
)
inline

Platform-independent arithmetic right shift.

Parameters
arginteger value in two's complement
ishift amount (at most 31)
Returns
arg right shifted for i bits with possible sign extension

Definition at line 707 of file half.hpp.

707 {
708 #if HALF_TWOS_COMPLEMENT_INT
709  return static_cast<int32>(arg) >> i;
710 #else
711  return static_cast<int32>(arg) / (static_cast<int32>(1) << i) - ((arg >> (std::numeric_limits<uint32>::digits - 1)) & 1);
712 #endif
713 }
714 
long int32
Fastest unsigned integer of (at least) 32 bits width.
Definition: half.hpp:599

◆ atan2()

uint32 half_float::detail::atan2 ( uint32  my,
uint32  mx,
unsigned int  n = 31 
)
inline

Fixed point arc tangent. This uses the CORDIC algorithm in vectoring mode.

Parameters
myy coordinate as Q0.30
mxx coordinate as Q0.30
nnumber of iterations (at most 31)
Returns
arc tangent of my / mx as Q1.30

Definition at line 4566 of file half.hpp.

4566 {
4567  static const uint32 angles[] = {
4568  0x3243F6A9,
4569  0x1DAC6705,
4570  0x0FADBAFD,
4571  0x07F56EA7,
4572  0x03FEAB77,
4573  0x01FFD55C,
4574  0x00FFFAAB,
4575  0x007FFF55,
4576  0x003FFFEB,
4577  0x001FFFFD,
4578  0x00100000,
4579  0x00080000,
4580  0x00040000,
4581  0x00020000,
4582  0x00010000,
4583  0x00008000,
4584  0x00004000,
4585  0x00002000,
4586  0x00001000,
4587  0x00000800,
4588  0x00000400,
4589  0x00000200,
4590  0x00000100,
4591  0x00000080,
4592  0x00000040,
4593  0x00000020,
4594  0x00000010,
4595  0x00000008,
4596  0x00000004,
4597  0x00000002,
4598  0x00000001};
4599  uint32 mz = 0;
4600  for (unsigned int i = 0; i < n; ++i)
4601  {
4602  uint32 sign = sign_mask(my);
4603  uint32 tx = mx + (arithmetic_shift(my, i) ^ sign) - sign;
4604  uint32 ty = my - (arithmetic_shift(mx, i) ^ sign) + sign;
4605  mx = tx;
4606  my = ty;
4607  mz += (angles[i] ^ sign) - sign;
4608  }
4609  return mz;
4610 }
4611 
uint32 arithmetic_shift(uint32 arg, int i)
Definition: half.hpp:707
uint32 sign_mask(uint32 arg)
Definition: half.hpp:693

◆ atan2_args()

std::pair<uint32, uint32> half_float::detail::atan2_args ( unsigned int  abs)
inline

Get arguments for atan2 function.

Parameters
abshalf-precision floating-point value
Returns
abs and sqrt(1 - abs^2) as Q0.30

Definition at line 4640 of file half.hpp.

4640 {
4641  int exp = -15;
4642  for (; abs < 0x400; abs <<= 1, --exp)
4643  ;
4644  exp += abs >> 10;
4645  uint32 my = ((abs & 0x3FF) | 0x400) << 5, r = my * my;
4646  int rexp = 2 * exp;
4647  r = 0x40000000 - ((rexp > -31) ? ((r >> -rexp) | ((r & ((static_cast<uint32>(1) << -rexp) - 1)) != 0)) : 1);
4648  for (rexp = 0; r < 0x40000000; r <<= 1, --rexp)
4649  ;
4650  uint32 mx = sqrt<30>(r, rexp);
4651  int d = exp - rexp;
4652  if (d < 0)
4653  return std::make_pair((d < -14) ? ((my >> (-d - 14)) + ((my >> (-d - 15)) & 1)) : (my << (14 + d)), (mx << 14) + (r << 13) / mx);
4654  if (d > 0)
4655  return std::make_pair(my << 14, (d > 14) ? ((mx >> (d - 14)) + ((mx >> (d - 15)) & 1)) : ((d == 14) ? mx : ((mx << (14 - d)) + (r << (13 - d)) / mx)));
4656  return std::make_pair(my << 13, (mx << 13) + (r << 12) / mx);
4657 }
4658 

◆ builtin_isinf()

template<typename T >
bool half_float::detail::builtin_isinf ( arg)

Check for infinity.

Template Parameters
Targument type (builtin floating-point type)
Parameters
argvalue to query
Return values
trueif infinity
falseelse

Definition at line 646 of file half.hpp.

646 {
647 #if HALF_ENABLE_CPP11_CMATH
648  return std::isinf(arg);
649 #elif defined(_MSC_VER)
650  return !::_finite(static_cast<double>(arg)) && !::_isnan(static_cast<double>(arg));
651 #else
652  return arg == std::numeric_limits<T>::infinity() || arg == -std::numeric_limits<T>::infinity();
653 #endif
654 }
655 
HALF_CONSTEXPR bool isinf(half arg)
Definition: half.hpp:7644

◆ builtin_isnan()

template<typename T >
bool half_float::detail::builtin_isnan ( arg)

Check for NaN.

Template Parameters
Targument type (builtin floating-point type)
Parameters
argvalue to query
Return values
trueif not a number
falseelse

Definition at line 663 of file half.hpp.

663 {
664 #if HALF_ENABLE_CPP11_CMATH
665  return std::isnan(arg);
666 #elif defined(_MSC_VER)
667  return ::_isnan(static_cast<double>(arg)) != 0;
668 #else
669  return arg != arg;
670 #endif
671 }
672 
HALF_CONSTEXPR bool isnan(half arg)
Definition: half.hpp:7654

◆ builtin_signbit()

template<typename T >
bool half_float::detail::builtin_signbit ( arg)

Check sign.

Template Parameters
Targument type (builtin floating-point type)
Parameters
argvalue to query
Return values
trueif signbit set
falseelse

Definition at line 680 of file half.hpp.

680 {
681 #if HALF_ENABLE_CPP11_CMATH
682  return std::signbit(arg);
683 #else
684  return arg < T() || (arg == T() && T(1) / arg < T());
685 #endif
686 }
687 
HALF_CONSTEXPR bool signbit(half arg)
Definition: half.hpp:7674

◆ check_underflow()

HALF_CONSTEXPR_NOERR unsigned int half_float::detail::check_underflow ( unsigned int  arg)
inline

Check value for underflow.

Parameters
argnon-zero half-precision value to check
Returns
arg
Exceptions
MU_HALF_FE_UNDERFLOWif arg is subnormal

Definition at line 874 of file half.hpp.

874 {
875 #if HALF_ERRHANDLING && !HALF_ERRHANDLING_UNDERFLOW_TO_INEXACT
876  raise(MU_HALF_FE_UNDERFLOW, !(arg & 0x7C00));
877 #endif
878  return arg;
879 }
880 
#define MU_HALF_FE_UNDERFLOW
Definition: half.hpp:44

◆ compsignal()

HALF_CONSTEXPR_NOERR bool half_float::detail::compsignal ( unsigned int  x,
unsigned int  y 
)
inline

Check and signal for any NaN.

Parameters
xfirst half-precision value to check
ysecond half-precision value to check
Return values
trueif either x or y is NaN
falseelse
Exceptions
MU_HALF_FE_INVALIDif x or y is NaN

Definition at line 785 of file half.hpp.

785 {
786 #if HALF_ERRHANDLING
787  raise(MU_HALF_FE_INVALID, (x & 0x7FFF) > 0x7C00 || (y & 0x7FFF) > 0x7C00);
788 #endif
789  return (x & 0x7FFF) > 0x7C00 || (y & 0x7FFF) > 0x7C00;
790 }
791 
#define MU_HALF_FE_INVALID
Definition: half.hpp:41

◆ divide64()

uint32 half_float::detail::divide64 ( uint32  x,
uint32  y,
int &  s 
)
inline

64-bit division.

Parameters
xupper 32 bit of dividend
ydivisor
svariable to store sticky bit for rounding
Returns
(x << 32) / y

Definition at line 4273 of file half.hpp.

4273 {
4274 #if HALF_ENABLE_CPP11_LONG_LONG
4275  unsigned long long xx = static_cast<unsigned long long>(x) << 32;
4276  return s = (xx % y != 0), static_cast<uint32>(xx / y);
4277 #else
4278  y >>= 1;
4279  uint32 rem = x, div = 0;
4280  for (unsigned int i = 0; i < 32; ++i)
4281  {
4282  div <<= 1;
4283  if (rem >= y)
4284  {
4285  rem -= y;
4286  div |= 1;
4287  }
4288  rem <<= 1;
4289  }
4290  return s = rem > 1, div;
4291 #endif
4292 }
4293 

◆ erf()

template<std::float_round_style R, bool C>
unsigned int half_float::detail::erf ( unsigned int  arg)

Error function and postprocessing. This computes the value directly in Q1.31 using the approximations given here.

Template Parameters
Rrounding mode to use
Ctrue for comlementary error function, false else
Parameters
arghalf-precision function argument
Returns
approximated value of error function in half-precision
Exceptions
MU_HALF_FE_OVERFLOWon overflows
MU_HALF_FE_UNDERFLOWon underflows
MU_HALF_FE_INEXACTif no other exception occurred

Definition at line 4949 of file half.hpp.

4949 {
4950  unsigned int abs = arg & 0x7FFF, sign = arg & 0x8000;
4951  f31 x(abs), x2 = x * x * f31(0xB8AA3B29, 0), t = f31(0x80000000, 0) / (f31(0x80000000, 0) + f31(0xA7BA054A, -2) * x), t2 = t * t;
4952  f31 e = ((f31(0x87DC2213, 0) * t2 + f31(0xB5F0E2AE, 0)) * t2 + f31(0x82790637, -2) - (f31(0xBA00E2B8, 0) * t2 + f31(0x91A98E62, -2)) * t) * t /
4953  ((x2.exp < 0) ? f31(exp2((x2.exp > -32) ? (x2.m >> -x2.exp) : 0, 30), 0) : f31(exp2((x2.m << x2.exp) & 0x7FFFFFFF, 22), x2.m >> (31 - x2.exp)));
4954  return (!C || sign) ? fixed2half<R, 31, false, true, true>(0x80000000 - (e.m >> (C - e.exp)), 14 + C, sign & (C - 1U)) : (e.exp < -25) ? underflow<R>()
4955  : fixed2half<R, 30, false, false, true>(e.m >> 1, e.exp + 14, 0, e.m & 1);
4956 }
4957 
unsigned int fixed2half(uint32 m, int exp=14, unsigned int sign=0, int s=0)
Definition: half.hpp:994
HALF_CONSTEXPR_NOERR unsigned int underflow(unsigned int sign=0)
Definition: half.hpp:908
half exp2(half arg)
Definition: half.hpp:6146

◆ errflags()

int& half_float::detail::errflags ( )
inline

Internal exception flags.

Returns
reference to global exception flags

Definition at line 722 of file half.hpp.

722 {
723  HALF_THREAD_LOCAL int flags = 0;
724  return flags;
725 }
726 
#define HALF_THREAD_LOCAL
Definition: half.hpp:252

◆ exp2()

uint32 half_float::detail::exp2 ( uint32  m,
unsigned int  n = 32 
)
inline

Fixed point binary exponential. This uses the BKM algorithm in E-mode.

Parameters
mexponent in [0,1) as Q0.31
nnumber of iterations (at most 32)
Returns
2 ^ m as Q1.31

Definition at line 4403 of file half.hpp.

4403 {
4404  static const uint32 logs[] = {
4405  0x80000000,
4406  0x4AE00D1D,
4407  0x2934F098,
4408  0x15C01A3A,
4409  0x0B31FB7D,
4410  0x05AEB4DD,
4411  0x02DCF2D1,
4412  0x016FE50B,
4413  0x00B84E23,
4414  0x005C3E10,
4415  0x002E24CA,
4416  0x001713D6,
4417  0x000B8A47,
4418  0x0005C53B,
4419  0x0002E2A3,
4420  0x00017153,
4421  0x0000B8AA,
4422  0x00005C55,
4423  0x00002E2B,
4424  0x00001715,
4425  0x00000B8B,
4426  0x000005C5,
4427  0x000002E3,
4428  0x00000171,
4429  0x000000B9,
4430  0x0000005C,
4431  0x0000002E,
4432  0x00000017,
4433  0x0000000C,
4434  0x00000006,
4435  0x00000003,
4436  0x00000001};
4437  if (!m)
4438  return 0x80000000;
4439  uint32 mx = 0x80000000, my = 0;
4440  for (unsigned int i = 1; i < n; ++i)
4441  {
4442  uint32 mz = my + logs[i];
4443  if (mz <= m)
4444  {
4445  my = mz;
4446  mx += mx >> i;
4447  }
4448  }
4449  return mx;
4450 }
4451 

◆ exp2_post()

template<std::float_round_style R>
unsigned int half_float::detail::exp2_post ( uint32  m,
int  exp,
bool  esign,
unsigned int  sign = 0,
unsigned int  n = 32 
)

Postprocessing for binary exponential.

Template Parameters
Rrounding mode to use
Parameters
mfractional part of as Q0.31
expabsolute value of unbiased exponent
esignsign of actual exponent
signsign bit of result
nnumber of BKM iterations (at most 32)
Returns
value converted to half-precision
Exceptions
MU_HALF_FE_OVERFLOWon overflows
MU_HALF_FE_UNDERFLOWon underflows
MU_HALF_FE_INEXACTif value had to be rounded or I is true

Definition at line 4704 of file half.hpp.

4704 {
4705  if (esign)
4706  {
4707  exp = -exp - (m != 0);
4708  if (exp < -25)
4709  return underflow<R>(sign);
4710  else if (exp == -25)
4711  return rounded<R, false>(sign, 1, m != 0);
4712  }
4713  else if (exp > 15)
4714  return overflow<R>(sign);
4715  if (!m)
4716  return sign | (((exp += 15) > 0) ? (exp << 10) : check_underflow(0x200 >> -exp));
4717  m = exp2(m, n);
4718  int s = 0;
4719  if (esign)
4720  m = divide64(0x80000000, m, s);
4721  return fixed2half<R, 31, false, false, true>(m, exp + 14, sign, s);
4722 }
4723 
HALF_CONSTEXPR_NOERR unsigned int check_underflow(unsigned int arg)
Definition: half.hpp:874
uint32 divide64(uint32 x, uint32 y, int &s)
Definition: half.hpp:4273

◆ fixed2half()

template<std::float_round_style R, unsigned int F, bool S, bool N, bool I>
unsigned int half_float::detail::fixed2half ( uint32  m,
int  exp = 14,
unsigned int  sign = 0,
int  s = 0 
)

Convert fixed point to half-precision floating-point.

Template Parameters
Rrounding mode to use
Fnumber of fractional bits in [11,31]
Strue for signed, false for unsigned
Ntrue for additional normalization step, false if already normalized to 1.F
Itrue to always raise INEXACT exception, false to raise only for rounded results
Parameters
mmantissa in Q1.F fixed point format
expbiased exponent - 1
signhalf-precision value with sign bit only
ssticky bit (or of all but the most significant already discarded bits)
Returns
value converted to half-precision
Exceptions
MU_HALF_FE_OVERFLOWon overflows
MU_HALF_FE_UNDERFLOWon underflows
MU_HALF_FE_INEXACTif value had to be rounded or I is true

Definition at line 994 of file half.hpp.

994 {
995  if (S)
996  {
997  uint32 msign = sign_mask(m);
998  m = (m ^ msign) - msign;
999  sign = msign & 0x8000;
1000  }
1001  if (N)
1002  for (; m < (static_cast<uint32>(1) << F) && exp; m <<= 1, --exp)
1003  ;
1004  else if (exp < 0)
1005  return rounded<R, I>(sign + (m >> (F - 10 - exp)), (m >> (F - 11 - exp)) & 1, s | ((m & ((static_cast<uint32>(1) << (F - 11 - exp)) - 1)) != 0));
1006  return rounded<R, I>(sign + (exp << 10) + (m >> (F - 10)), (m >> (F - 11)) & 1, s | ((m & ((static_cast<uint32>(1) << (F - 11)) - 1)) != 0));
1007 }
1008 

◆ float2half()

template<std::float_round_style R, typename T >
unsigned int half_float::detail::float2half ( value)

Convert floating-point to half-precision.

Template Parameters
Rrounding mode to use
Tsource type (builtin floating-point type)
Parameters
valuefloating-point value to convert
Returns
rounded half-precision value
Exceptions
MU_HALF_FE_OVERFLOWon overflows
MU_HALF_FE_UNDERFLOWon underflows
MU_HALF_FE_INEXACTif value had to be rounded

Definition at line 1906 of file half.hpp.

1906 {
1907  return float2half_impl<R>(value, bool_type<std::numeric_limits<T>::is_iec559 && sizeof(typename bits<T>::type) == sizeof(T)>());
1908 }
1909 

◆ float2half_impl() [1/3]

template<std::float_round_style R>
unsigned int half_float::detail::float2half_impl ( double  value,
true_type   
)

Convert IEEE double-precision to half-precision.

Template Parameters
Rrounding mode to use
Parameters
valuedouble-precision value to convert
Returns
rounded half-precision value
Exceptions
MU_HALF_FE_OVERFLOWon overflows
MU_HALF_FE_UNDERFLOWon underflows
MU_HALF_FE_INEXACTif value had to be rounded

Definition at line 1835 of file half.hpp.

1835 {
1836 #if HALF_ENABLE_F16C_INTRINSICS
1837  if (R == std::round_indeterminate)
1838  return _mm_cvtsi128_si32(_mm_cvtps_ph(_mm_cvtpd_ps(_mm_set_sd(value)), _MM_FROUND_CUR_DIRECTION));
1839 #endif
1840  bits<double>::type dbits;
1841  std::memcpy(&dbits, &value, sizeof(double));
1842  uint32 hi = dbits >> 32, lo = dbits & 0xFFFFFFFF;
1843  unsigned int sign = (hi >> 16) & 0x8000;
1844  hi &= 0x7FFFFFFF;
1845  if (hi >= 0x7FF00000)
1846  return sign | 0x7C00 | ((dbits & 0xFFFFFFFFFFFFF) ? (0x200 | ((hi >> 10) & 0x3FF)) : 0);
1847  if (hi >= 0x40F00000)
1848  return overflow<R>(sign);
1849  if (hi >= 0x3F100000)
1850  return rounded<R, false>(sign | (((hi >> 20) - 1008) << 10) | ((hi >> 10) & 0x3FF), (hi >> 9) & 1, ((hi & 0x1FF) | lo) != 0);
1851  if (hi >= 0x3E600000)
1852  {
1853  int i = 1018 - (hi >> 20);
1854  hi = (hi & 0xFFFFF) | 0x100000;
1855  return rounded<R, false>(sign | (hi >> (i + 1)), (hi >> i) & 1, ((hi & ((static_cast<uint32>(1) << i) - 1)) | lo) != 0);
1856  }
1857  if ((hi | lo) != 0)
1858  return underflow<R>(sign);
1859  return sign;
1860 }
1861 

◆ float2half_impl() [2/3]

template<std::float_round_style R>
unsigned int half_float::detail::float2half_impl ( float  value,
true_type   
)

Convert IEEE single-precision to half-precision. Credit for this goes to Jeroen van der Zijp.

Template Parameters
Rrounding mode to use
Parameters
valuesingle-precision value to convert
Returns
rounded half-precision value
Exceptions
MU_HALF_FE_OVERFLOWon overflows
MU_HALF_FE_UNDERFLOWon underflows
MU_HALF_FE_INEXACTif value had to be rounded

Definition at line 1019 of file half.hpp.

1019 {
1020 #if HALF_ENABLE_F16C_INTRINSICS
1021  return _mm_cvtsi128_si32(_mm_cvtps_ph(_mm_set_ss(value),
1022  (R == std::round_to_nearest) ? _MM_FROUND_TO_NEAREST_INT : (R == std::round_toward_zero) ? _MM_FROUND_TO_ZERO
1023  : (R == std::round_toward_infinity) ? _MM_FROUND_TO_POS_INF
1024  : (R == std::round_toward_neg_infinity) ? _MM_FROUND_TO_NEG_INF
1025  : _MM_FROUND_CUR_DIRECTION));
1026 #else
1027  bits<float>::type fbits;
1028  std::memcpy(&fbits, &value, sizeof(float));
1029 #if 1
1030  unsigned int sign = (fbits >> 16) & 0x8000;
1031  fbits &= 0x7FFFFFFF;
1032  if (fbits >= 0x7F800000)
1033  return sign | 0x7C00 | ((fbits > 0x7F800000) ? (0x200 | ((fbits >> 13) & 0x3FF)) : 0);
1034  if (fbits >= 0x47800000)
1035  return overflow<R>(sign);
1036  if (fbits >= 0x38800000)
1037  return rounded<R, false>(sign | (((fbits >> 23) - 112) << 10) | ((fbits >> 13) & 0x3FF), (fbits >> 12) & 1, (fbits & 0xFFF) != 0);
1038  if (fbits >= 0x33000000)
1039  {
1040  int i = 125 - (fbits >> 23);
1041  fbits = (fbits & 0x7FFFFF) | 0x800000;
1042  return rounded<R, false>(sign | (fbits >> (i + 1)), (fbits >> i) & 1, (fbits & ((static_cast<uint32>(1) << i) - 1)) != 0);
1043  }
1044  if (fbits != 0)
1045  return underflow<R>(sign);
1046  return sign;
1047 #else
1048  static const uint16 base_table[512] = {
1049  0x0000,
1050  0x0000,
1051  0x0000,
1052  0x0000,
1053  0x0000,
1054  0x0000,
1055  0x0000,
1056  0x0000,
1057  0x0000,
1058  0x0000,
1059  0x0000,
1060  0x0000,
1061  0x0000,
1062  0x0000,
1063  0x0000,
1064  0x0000,
1065  0x0000,
1066  0x0000,
1067  0x0000,
1068  0x0000,
1069  0x0000,
1070  0x0000,
1071  0x0000,
1072  0x0000,
1073  0x0000,
1074  0x0000,
1075  0x0000,
1076  0x0000,
1077  0x0000,
1078  0x0000,
1079  0x0000,
1080  0x0000,
1081  0x0000,
1082  0x0000,
1083  0x0000,
1084  0x0000,
1085  0x0000,
1086  0x0000,
1087  0x0000,
1088  0x0000,
1089  0x0000,
1090  0x0000,
1091  0x0000,
1092  0x0000,
1093  0x0000,
1094  0x0000,
1095  0x0000,
1096  0x0000,
1097  0x0000,
1098  0x0000,
1099  0x0000,
1100  0x0000,
1101  0x0000,
1102  0x0000,
1103  0x0000,
1104  0x0000,
1105  0x0000,
1106  0x0000,
1107  0x0000,
1108  0x0000,
1109  0x0000,
1110  0x0000,
1111  0x0000,
1112  0x0000,
1113  0x0000,
1114  0x0000,
1115  0x0000,
1116  0x0000,
1117  0x0000,
1118  0x0000,
1119  0x0000,
1120  0x0000,
1121  0x0000,
1122  0x0000,
1123  0x0000,
1124  0x0000,
1125  0x0000,
1126  0x0000,
1127  0x0000,
1128  0x0000,
1129  0x0000,
1130  0x0000,
1131  0x0000,
1132  0x0000,
1133  0x0000,
1134  0x0000,
1135  0x0000,
1136  0x0000,
1137  0x0000,
1138  0x0000,
1139  0x0000,
1140  0x0000,
1141  0x0000,
1142  0x0000,
1143  0x0000,
1144  0x0000,
1145  0x0000,
1146  0x0000,
1147  0x0000,
1148  0x0000,
1149  0x0000,
1150  0x0000,
1151  0x0000,
1152  0x0001,
1153  0x0002,
1154  0x0004,
1155  0x0008,
1156  0x0010,
1157  0x0020,
1158  0x0040,
1159  0x0080,
1160  0x0100,
1161  0x0200,
1162  0x0400,
1163  0x0800,
1164  0x0C00,
1165  0x1000,
1166  0x1400,
1167  0x1800,
1168  0x1C00,
1169  0x2000,
1170  0x2400,
1171  0x2800,
1172  0x2C00,
1173  0x3000,
1174  0x3400,
1175  0x3800,
1176  0x3C00,
1177  0x4000,
1178  0x4400,
1179  0x4800,
1180  0x4C00,
1181  0x5000,
1182  0x5400,
1183  0x5800,
1184  0x5C00,
1185  0x6000,
1186  0x6400,
1187  0x6800,
1188  0x6C00,
1189  0x7000,
1190  0x7400,
1191  0x7800,
1192  0x7BFF,
1193  0x7BFF,
1194  0x7BFF,
1195  0x7BFF,
1196  0x7BFF,
1197  0x7BFF,
1198  0x7BFF,
1199  0x7BFF,
1200  0x7BFF,
1201  0x7BFF,
1202  0x7BFF,
1203  0x7BFF,
1204  0x7BFF,
1205  0x7BFF,
1206  0x7BFF,
1207  0x7BFF,
1208  0x7BFF,
1209  0x7BFF,
1210  0x7BFF,
1211  0x7BFF,
1212  0x7BFF,
1213  0x7BFF,
1214  0x7BFF,
1215  0x7BFF,
1216  0x7BFF,
1217  0x7BFF,
1218  0x7BFF,
1219  0x7BFF,
1220  0x7BFF,
1221  0x7BFF,
1222  0x7BFF,
1223  0x7BFF,
1224  0x7BFF,
1225  0x7BFF,
1226  0x7BFF,
1227  0x7BFF,
1228  0x7BFF,
1229  0x7BFF,
1230  0x7BFF,
1231  0x7BFF,
1232  0x7BFF,
1233  0x7BFF,
1234  0x7BFF,
1235  0x7BFF,
1236  0x7BFF,
1237  0x7BFF,
1238  0x7BFF,
1239  0x7BFF,
1240  0x7BFF,
1241  0x7BFF,
1242  0x7BFF,
1243  0x7BFF,
1244  0x7BFF,
1245  0x7BFF,
1246  0x7BFF,
1247  0x7BFF,
1248  0x7BFF,
1249  0x7BFF,
1250  0x7BFF,
1251  0x7BFF,
1252  0x7BFF,
1253  0x7BFF,
1254  0x7BFF,
1255  0x7BFF,
1256  0x7BFF,
1257  0x7BFF,
1258  0x7BFF,
1259  0x7BFF,
1260  0x7BFF,
1261  0x7BFF,
1262  0x7BFF,
1263  0x7BFF,
1264  0x7BFF,
1265  0x7BFF,
1266  0x7BFF,
1267  0x7BFF,
1268  0x7BFF,
1269  0x7BFF,
1270  0x7BFF,
1271  0x7BFF,
1272  0x7BFF,
1273  0x7BFF,
1274  0x7BFF,
1275  0x7BFF,
1276  0x7BFF,
1277  0x7BFF,
1278  0x7BFF,
1279  0x7BFF,
1280  0x7BFF,
1281  0x7BFF,
1282  0x7BFF,
1283  0x7BFF,
1284  0x7BFF,
1285  0x7BFF,
1286  0x7BFF,
1287  0x7BFF,
1288  0x7BFF,
1289  0x7BFF,
1290  0x7BFF,
1291  0x7BFF,
1292  0x7BFF,
1293  0x7BFF,
1294  0x7BFF,
1295  0x7BFF,
1296  0x7BFF,
1297  0x7BFF,
1298  0x7BFF,
1299  0x7BFF,
1300  0x7BFF,
1301  0x7BFF,
1302  0x7BFF,
1303  0x7BFF,
1304  0x7C00,
1305  0x8000,
1306  0x8000,
1307  0x8000,
1308  0x8000,
1309  0x8000,
1310  0x8000,
1311  0x8000,
1312  0x8000,
1313  0x8000,
1314  0x8000,
1315  0x8000,
1316  0x8000,
1317  0x8000,
1318  0x8000,
1319  0x8000,
1320  0x8000,
1321  0x8000,
1322  0x8000,
1323  0x8000,
1324  0x8000,
1325  0x8000,
1326  0x8000,
1327  0x8000,
1328  0x8000,
1329  0x8000,
1330  0x8000,
1331  0x8000,
1332  0x8000,
1333  0x8000,
1334  0x8000,
1335  0x8000,
1336  0x8000,
1337  0x8000,
1338  0x8000,
1339  0x8000,
1340  0x8000,
1341  0x8000,
1342  0x8000,
1343  0x8000,
1344  0x8000,
1345  0x8000,
1346  0x8000,
1347  0x8000,
1348  0x8000,
1349  0x8000,
1350  0x8000,
1351  0x8000,
1352  0x8000,
1353  0x8000,
1354  0x8000,
1355  0x8000,
1356  0x8000,
1357  0x8000,
1358  0x8000,
1359  0x8000,
1360  0x8000,
1361  0x8000,
1362  0x8000,
1363  0x8000,
1364  0x8000,
1365  0x8000,
1366  0x8000,
1367  0x8000,
1368  0x8000,
1369  0x8000,
1370  0x8000,
1371  0x8000,
1372  0x8000,
1373  0x8000,
1374  0x8000,
1375  0x8000,
1376  0x8000,
1377  0x8000,
1378  0x8000,
1379  0x8000,
1380  0x8000,
1381  0x8000,
1382  0x8000,
1383  0x8000,
1384  0x8000,
1385  0x8000,
1386  0x8000,
1387  0x8000,
1388  0x8000,
1389  0x8000,
1390  0x8000,
1391  0x8000,
1392  0x8000,
1393  0x8000,
1394  0x8000,
1395  0x8000,
1396  0x8000,
1397  0x8000,
1398  0x8000,
1399  0x8000,
1400  0x8000,
1401  0x8000,
1402  0x8000,
1403  0x8000,
1404  0x8000,
1405  0x8000,
1406  0x8000,
1407  0x8000,
1408  0x8001,
1409  0x8002,
1410  0x8004,
1411  0x8008,
1412  0x8010,
1413  0x8020,
1414  0x8040,
1415  0x8080,
1416  0x8100,
1417  0x8200,
1418  0x8400,
1419  0x8800,
1420  0x8C00,
1421  0x9000,
1422  0x9400,
1423  0x9800,
1424  0x9C00,
1425  0xA000,
1426  0xA400,
1427  0xA800,
1428  0xAC00,
1429  0xB000,
1430  0xB400,
1431  0xB800,
1432  0xBC00,
1433  0xC000,
1434  0xC400,
1435  0xC800,
1436  0xCC00,
1437  0xD000,
1438  0xD400,
1439  0xD800,
1440  0xDC00,
1441  0xE000,
1442  0xE400,
1443  0xE800,
1444  0xEC00,
1445  0xF000,
1446  0xF400,
1447  0xF800,
1448  0xFBFF,
1449  0xFBFF,
1450  0xFBFF,
1451  0xFBFF,
1452  0xFBFF,
1453  0xFBFF,
1454  0xFBFF,
1455  0xFBFF,
1456  0xFBFF,
1457  0xFBFF,
1458  0xFBFF,
1459  0xFBFF,
1460  0xFBFF,
1461  0xFBFF,
1462  0xFBFF,
1463  0xFBFF,
1464  0xFBFF,
1465  0xFBFF,
1466  0xFBFF,
1467  0xFBFF,
1468  0xFBFF,
1469  0xFBFF,
1470  0xFBFF,
1471  0xFBFF,
1472  0xFBFF,
1473  0xFBFF,
1474  0xFBFF,
1475  0xFBFF,
1476  0xFBFF,
1477  0xFBFF,
1478  0xFBFF,
1479  0xFBFF,
1480  0xFBFF,
1481  0xFBFF,
1482  0xFBFF,
1483  0xFBFF,
1484  0xFBFF,
1485  0xFBFF,
1486  0xFBFF,
1487  0xFBFF,
1488  0xFBFF,
1489  0xFBFF,
1490  0xFBFF,
1491  0xFBFF,
1492  0xFBFF,
1493  0xFBFF,
1494  0xFBFF,
1495  0xFBFF,
1496  0xFBFF,
1497  0xFBFF,
1498  0xFBFF,
1499  0xFBFF,
1500  0xFBFF,
1501  0xFBFF,
1502  0xFBFF,
1503  0xFBFF,
1504  0xFBFF,
1505  0xFBFF,
1506  0xFBFF,
1507  0xFBFF,
1508  0xFBFF,
1509  0xFBFF,
1510  0xFBFF,
1511  0xFBFF,
1512  0xFBFF,
1513  0xFBFF,
1514  0xFBFF,
1515  0xFBFF,
1516  0xFBFF,
1517  0xFBFF,
1518  0xFBFF,
1519  0xFBFF,
1520  0xFBFF,
1521  0xFBFF,
1522  0xFBFF,
1523  0xFBFF,
1524  0xFBFF,
1525  0xFBFF,
1526  0xFBFF,
1527  0xFBFF,
1528  0xFBFF,
1529  0xFBFF,
1530  0xFBFF,
1531  0xFBFF,
1532  0xFBFF,
1533  0xFBFF,
1534  0xFBFF,
1535  0xFBFF,
1536  0xFBFF,
1537  0xFBFF,
1538  0xFBFF,
1539  0xFBFF,
1540  0xFBFF,
1541  0xFBFF,
1542  0xFBFF,
1543  0xFBFF,
1544  0xFBFF,
1545  0xFBFF,
1546  0xFBFF,
1547  0xFBFF,
1548  0xFBFF,
1549  0xFBFF,
1550  0xFBFF,
1551  0xFBFF,
1552  0xFBFF,
1553  0xFBFF,
1554  0xFBFF,
1555  0xFBFF,
1556  0xFBFF,
1557  0xFBFF,
1558  0xFBFF,
1559  0xFBFF,
1560  0xFC00};
1561  static const unsigned char shift_table[256] = {
1562  24,
1563  25,
1564  25,
1565  25,
1566  25,
1567  25,
1568  25,
1569  25,
1570  25,
1571  25,
1572  25,
1573  25,
1574  25,
1575  25,
1576  25,
1577  25,
1578  25,
1579  25,
1580  25,
1581  25,
1582  25,
1583  25,
1584  25,
1585  25,
1586  25,
1587  25,
1588  25,
1589  25,
1590  25,
1591  25,
1592  25,
1593  25,
1594  25,
1595  25,
1596  25,
1597  25,
1598  25,
1599  25,
1600  25,
1601  25,
1602  25,
1603  25,
1604  25,
1605  25,
1606  25,
1607  25,
1608  25,
1609  25,
1610  25,
1611  25,
1612  25,
1613  25,
1614  25,
1615  25,
1616  25,
1617  25,
1618  25,
1619  25,
1620  25,
1621  25,
1622  25,
1623  25,
1624  25,
1625  25,
1626  25,
1627  25,
1628  25,
1629  25,
1630  25,
1631  25,
1632  25,
1633  25,
1634  25,
1635  25,
1636  25,
1637  25,
1638  25,
1639  25,
1640  25,
1641  25,
1642  25,
1643  25,
1644  25,
1645  25,
1646  25,
1647  25,
1648  25,
1649  25,
1650  25,
1651  25,
1652  25,
1653  25,
1654  25,
1655  25,
1656  25,
1657  25,
1658  25,
1659  25,
1660  25,
1661  25,
1662  25,
1663  25,
1664  24,
1665  23,
1666  22,
1667  21,
1668  20,
1669  19,
1670  18,
1671  17,
1672  16,
1673  15,
1674  14,
1675  13,
1676  13,
1677  13,
1678  13,
1679  13,
1680  13,
1681  13,
1682  13,
1683  13,
1684  13,
1685  13,
1686  13,
1687  13,
1688  13,
1689  13,
1690  13,
1691  13,
1692  13,
1693  13,
1694  13,
1695  13,
1696  13,
1697  13,
1698  13,
1699  13,
1700  13,
1701  13,
1702  13,
1703  13,
1704  13,
1705  24,
1706  24,
1707  24,
1708  24,
1709  24,
1710  24,
1711  24,
1712  24,
1713  24,
1714  24,
1715  24,
1716  24,
1717  24,
1718  24,
1719  24,
1720  24,
1721  24,
1722  24,
1723  24,
1724  24,
1725  24,
1726  24,
1727  24,
1728  24,
1729  24,
1730  24,
1731  24,
1732  24,
1733  24,
1734  24,
1735  24,
1736  24,
1737  24,
1738  24,
1739  24,
1740  24,
1741  24,
1742  24,
1743  24,
1744  24,
1745  24,
1746  24,
1747  24,
1748  24,
1749  24,
1750  24,
1751  24,
1752  24,
1753  24,
1754  24,
1755  24,
1756  24,
1757  24,
1758  24,
1759  24,
1760  24,
1761  24,
1762  24,
1763  24,
1764  24,
1765  24,
1766  24,
1767  24,
1768  24,
1769  24,
1770  24,
1771  24,
1772  24,
1773  24,
1774  24,
1775  24,
1776  24,
1777  24,
1778  24,
1779  24,
1780  24,
1781  24,
1782  24,
1783  24,
1784  24,
1785  24,
1786  24,
1787  24,
1788  24,
1789  24,
1790  24,
1791  24,
1792  24,
1793  24,
1794  24,
1795  24,
1796  24,
1797  24,
1798  24,
1799  24,
1800  24,
1801  24,
1802  24,
1803  24,
1804  24,
1805  24,
1806  24,
1807  24,
1808  24,
1809  24,
1810  24,
1811  24,
1812  24,
1813  24,
1814  24,
1815  24,
1816  24,
1817  13};
1818  int sexp = fbits >> 23, exp = sexp & 0xFF, i = shift_table[exp];
1819  fbits &= 0x7FFFFF;
1820  uint32 m = (fbits | ((exp != 0) << 23)) & -static_cast<uint32>(exp != 0xFF);
1821  return rounded<R, false>(base_table[sexp] + (fbits >> i), (m >> (i - 1)) & 1, (((static_cast<uint32>(1) << (i - 1)) - 1) & m) != 0);
1822 #endif
1823 #endif
1824 }
1825 
unsigned short uint16
Unsigned integer of (at least) 16 bits width.
Definition: half.hpp:593

◆ float2half_impl() [3/3]

template<std::float_round_style R, typename T >
unsigned int half_float::detail::float2half_impl ( value,
  ... 
)

Convert non-IEEE floating-point to half-precision.

Template Parameters
Rrounding mode to use
Tsource type (builtin floating-point type)
Parameters
valuefloating-point value to convert
Returns
rounded half-precision value
Exceptions
MU_HALF_FE_OVERFLOWon overflows
MU_HALF_FE_UNDERFLOWon underflows
MU_HALF_FE_INEXACTif value had to be rounded

Definition at line 1872 of file half.hpp.

1872 {
1873  unsigned int hbits = static_cast<unsigned>(builtin_signbit(value)) << 15;
1874  if (value == T())
1875  return hbits;
1876  if (builtin_isnan(value))
1877  return hbits | 0x7FFF;
1878  if (builtin_isinf(value))
1879  return hbits | 0x7C00;
1880  int exp;
1881  frexp(value, &exp);
1882  if (exp > 16)
1883  return overflow<R>(hbits);
1884  if (exp < -13)
1885  value = std::ldexp(value, 25);
1886  else
1887  {
1888  value = std::ldexp(value, 12 - exp);
1889  hbits |= ((exp + 13) << 10);
1890  }
1891  T ival, frac = std::modf(value, &ival);
1892  int m = std::abs(static_cast<int>(ival));
1893  return rounded<R, false>(hbits + (m >> 1), m & 1, frac != T());
1894 }
1895 
bool builtin_signbit(T arg)
Definition: half.hpp:680
bool builtin_isnan(T arg)
Definition: half.hpp:663
bool builtin_isinf(T arg)
Definition: half.hpp:646
half ldexp(half arg, int exp)
Definition: half.hpp:7465
half frexp(half arg, int *exp)
Definition: half.hpp:7403
half modf(half arg, half *iptr)
Definition: half.hpp:7476

◆ gamma()

template<std::float_round_style R, bool L>
unsigned int half_float::detail::gamma ( unsigned int  arg)

Gamma function and postprocessing. This approximates the value of either the gamma function or its logarithm directly in Q1.31.

Template Parameters
Rrounding mode to use
Ltrue for lograithm of gamma function, false for gamma function
Parameters
arghalf-precision floating-point value
Returns
lgamma/tgamma(arg) in half-precision
Exceptions
MU_HALF_FE_OVERFLOWon overflows
MU_HALF_FE_UNDERFLOWon underflows
MU_HALF_FE_INEXACTif arg is not a positive integer

Definition at line 4969 of file half.hpp.

4969 {
4970  /* static const double p[] ={ 2.50662827563479526904, 225.525584619175212544, -268.295973841304927459, 80.9030806934622512966, -5.00757863970517583837, 0.0114684895434781459556 };
4971  double t = arg + 4.65, s = p[0];
4972  for(unsigned int i=0; i<5; ++i)
4973  s += p[i+1] / (arg+i);
4974  return std::log(s) + (arg-0.5)*std::log(t) - t;
4975  */
4976  static const f31 pi(0xC90FDAA2, 1), lbe(0xB8AA3B29, 0);
4977  unsigned int abs = arg & 0x7FFF, sign = arg & 0x8000;
4978  bool bsign = sign != 0;
4979  f31 z(abs), x = sign ? (z + f31(0x80000000, 0)) : z, t = x + f31(0x94CCCCCD, 2), s = f31(0xA06C9901, 1) + f31(0xBBE654E2, -7) / (x + f31(0x80000000, 2)) + f31(0xA1CE6098, 6) / (x + f31(0x80000000, 1)) + f31(0xE1868CB7, 7) / x - f31(0x8625E279, 8) / (x + f31(0x80000000, 0)) - f31(0xA03E158F, 2) / (x + f31(0xC0000000, 1));
4980  int i = (s.exp >= 2) + (s.exp >= 4) + (s.exp >= 8) + (s.exp >= 16);
4981  s = f31((static_cast<uint32>(s.exp) << (31 - i)) + (log2(s.m >> 1, 28) >> i), i) / lbe;
4982  if (x.exp != -1 || x.m != 0x80000000)
4983  {
4984  i = (t.exp >= 2) + (t.exp >= 4) + (t.exp >= 8);
4985  f31 l = f31((static_cast<uint32>(t.exp) << (31 - i)) + (log2(t.m >> 1, 30) >> i), i) / lbe;
4986  s = (x.exp < -1) ? (s - (f31(0x80000000, -1) - x) * l) : (s + (x - f31(0x80000000, -1)) * l);
4987  }
4988  s = x.exp ? (s - t) : (t - s);
4989  if (bsign)
4990  {
4991  if (z.exp >= 0)
4992  {
4993  sign &= (L | ((z.m >> (31 - z.exp)) & 1)) - 1;
4994  for (z = f31((z.m << (1 + z.exp)) & 0xFFFFFFFF, -1); z.m < 0x80000000; z.m <<= 1, --z.exp)
4995  ;
4996  }
4997  if (z.exp == -1)
4998  z = f31(0x80000000, 0) - z;
4999  if (z.exp < -1)
5000  {
5001  z = z * pi;
5002  z.m = sincos(z.m >> (1 - z.exp), 30).first;
5003  for (z.exp = 1; z.m < 0x80000000; z.m <<= 1, --z.exp)
5004  ;
5005  }
5006  else
5007  z = f31(0x80000000, 0);
5008  }
5009  if (L)
5010  {
5011  if (bsign)
5012  {
5013  f31 l(0x92868247, 0);
5014  if (z.exp < 0)
5015  {
5016  uint32 m = log2((z.m + 1) >> 1, 27);
5017  z = f31(-((static_cast<uint32>(z.exp) << 26) + (m >> 5)), 5);
5018  for (; z.m < 0x80000000; z.m <<= 1, --z.exp)
5019  ;
5020  l = l + z / lbe;
5021  }
5022  sign = static_cast<unsigned>(x.exp && (l.exp < s.exp || (l.exp == s.exp && l.m < s.m))) << 15;
5023  s = sign ? (s - l) : x.exp ? (l - s)
5024  : (l + s);
5025  }
5026  else
5027  {
5028  sign = static_cast<unsigned>(x.exp == 0) << 15;
5029  if (s.exp < -24)
5030  return underflow<R>(sign);
5031  if (s.exp > 15)
5032  return overflow<R>(sign);
5033  }
5034  }
5035  else
5036  {
5037  s = s * lbe;
5038  uint32 m;
5039  if (s.exp < 0)
5040  {
5041  m = s.m >> -s.exp;
5042  s.exp = 0;
5043  }
5044  else
5045  {
5046  m = (s.m << s.exp) & 0x7FFFFFFF;
5047  s.exp = (s.m >> (31 - s.exp));
5048  }
5049  s.m = exp2(m, 27);
5050  if (!x.exp)
5051  s = f31(0x80000000, 0) / s;
5052  if (bsign)
5053  {
5054  if (z.exp < 0)
5055  s = s * z;
5056  s = pi / s;
5057  if (s.exp < -24)
5058  return underflow<R>(sign);
5059  }
5060  else if (z.exp > 0 && !(z.m & ((1 << (31 - z.exp)) - 1)))
5061  return ((s.exp + 14) << 10) + (s.m >> 21);
5062  if (s.exp > 15)
5063  return overflow<R>(sign);
5064  }
5065  return fixed2half<R, 31, false, false, true>(s.m, s.exp + 14, sign);
5066 }
friend half exp(half)
Definition: half.hpp:6111
void sincos(half arg, half *sin, half *cos)
Definition: half.hpp:6690

◆ half2float()

template<typename T >
T half_float::detail::half2float ( unsigned int  value)

Convert half-precision to floating-point.

Template Parameters
Ttype to convert to (builtin integer type)
Parameters
valuehalf-precision value to convert
Returns
floating-point value

Definition at line 4194 of file half.hpp.

4194 {
4195  return half2float_impl(value, T(), bool_type<std::numeric_limits<T>::is_iec559 && sizeof(typename bits<T>::type) == sizeof(T)>());
4196 }
4197 
T half2float_impl(unsigned int value, T,...)
Definition: half.hpp:4173

◆ half2float_impl() [1/3]

double half_float::detail::half2float_impl ( unsigned int  value,
double  ,
true_type   
)
inline

Convert half-precision to IEEE double-precision.

Parameters
valuehalf-precision value to convert
Returns
double-precision value

Definition at line 4147 of file half.hpp.

4147 {
4148 #if HALF_ENABLE_F16C_INTRINSICS
4149  return _mm_cvtsd_f64(_mm_cvtps_pd(_mm_cvtph_ps(_mm_cvtsi32_si128(value))));
4150 #else
4151  uint32 hi = static_cast<uint32>(value & 0x8000) << 16;
4152  unsigned int abs = value & 0x7FFF;
4153  if (abs)
4154  {
4155  hi |= 0x3F000000 << static_cast<unsigned>(abs >= 0x7C00);
4156  for (; abs < 0x400; abs <<= 1, hi -= 0x100000)
4157  ;
4158  hi += static_cast<uint32>(abs) << 10;
4159  }
4160  bits<double>::type dbits = static_cast<bits<double>::type>(hi) << 32;
4161  double out;
4162  std::memcpy(&out, &dbits, sizeof(double));
4163  return out;
4164 #endif
4165 }
4166 

◆ half2float_impl() [2/3]

float half_float::detail::half2float_impl ( unsigned int  value,
float  ,
true_type   
)
inline

Convert half-precision to IEEE single-precision. Credit for this goes to Jeroen van der Zijp.

Parameters
valuehalf-precision value to convert
Returns
single-precision value

Definition at line 1941 of file half.hpp.

1941 {
1942 #if HALF_ENABLE_F16C_INTRINSICS
1943  return _mm_cvtss_f32(_mm_cvtph_ps(_mm_cvtsi32_si128(value)));
1944 #else
1945 #if 1
1946  bits<float>::type fbits = static_cast<bits<float>::type>(value & 0x8000) << 16;
1947  int abs = value & 0x7FFF;
1948  if (abs)
1949  {
1950  fbits |= 0x38000000 << static_cast<unsigned>(abs >= 0x7C00);
1951  for (; abs < 0x400; abs <<= 1, fbits -= 0x800000)
1952  ;
1953  fbits += static_cast<bits<float>::type>(abs) << 13;
1954  }
1955 #else
1956  static const bits<float>::type mantissa_table[2048] = {
1957  0x00000000,
1958  0x33800000,
1959  0x34000000,
1960  0x34400000,
1961  0x34800000,
1962  0x34A00000,
1963  0x34C00000,
1964  0x34E00000,
1965  0x35000000,
1966  0x35100000,
1967  0x35200000,
1968  0x35300000,
1969  0x35400000,
1970  0x35500000,
1971  0x35600000,
1972  0x35700000,
1973  0x35800000,
1974  0x35880000,
1975  0x35900000,
1976  0x35980000,
1977  0x35A00000,
1978  0x35A80000,
1979  0x35B00000,
1980  0x35B80000,
1981  0x35C00000,
1982  0x35C80000,
1983  0x35D00000,
1984  0x35D80000,
1985  0x35E00000,
1986  0x35E80000,
1987  0x35F00000,
1988  0x35F80000,
1989  0x36000000,
1990  0x36040000,
1991  0x36080000,
1992  0x360C0000,
1993  0x36100000,
1994  0x36140000,
1995  0x36180000,
1996  0x361C0000,
1997  0x36200000,
1998  0x36240000,
1999  0x36280000,
2000  0x362C0000,
2001  0x36300000,
2002  0x36340000,
2003  0x36380000,
2004  0x363C0000,
2005  0x36400000,
2006  0x36440000,
2007  0x36480000,
2008  0x364C0000,
2009  0x36500000,
2010  0x36540000,
2011  0x36580000,
2012  0x365C0000,
2013  0x36600000,
2014  0x36640000,
2015  0x36680000,
2016  0x366C0000,
2017  0x36700000,
2018  0x36740000,
2019  0x36780000,
2020  0x367C0000,
2021  0x36800000,
2022  0x36820000,
2023  0x36840000,
2024  0x36860000,
2025  0x36880000,
2026  0x368A0000,
2027  0x368C0000,
2028  0x368E0000,
2029  0x36900000,
2030  0x36920000,
2031  0x36940000,
2032  0x36960000,
2033  0x36980000,
2034  0x369A0000,
2035  0x369C0000,
2036  0x369E0000,
2037  0x36A00000,
2038  0x36A20000,
2039  0x36A40000,
2040  0x36A60000,
2041  0x36A80000,
2042  0x36AA0000,
2043  0x36AC0000,
2044  0x36AE0000,
2045  0x36B00000,
2046  0x36B20000,
2047  0x36B40000,
2048  0x36B60000,
2049  0x36B80000,
2050  0x36BA0000,
2051  0x36BC0000,
2052  0x36BE0000,
2053  0x36C00000,
2054  0x36C20000,
2055  0x36C40000,
2056  0x36C60000,
2057  0x36C80000,
2058  0x36CA0000,
2059  0x36CC0000,
2060  0x36CE0000,
2061  0x36D00000,
2062  0x36D20000,
2063  0x36D40000,
2064  0x36D60000,
2065  0x36D80000,
2066  0x36DA0000,
2067  0x36DC0000,
2068  0x36DE0000,
2069  0x36E00000,
2070  0x36E20000,
2071  0x36E40000,
2072  0x36E60000,
2073  0x36E80000,
2074  0x36EA0000,
2075  0x36EC0000,
2076  0x36EE0000,
2077  0x36F00000,
2078  0x36F20000,
2079  0x36F40000,
2080  0x36F60000,
2081  0x36F80000,
2082  0x36FA0000,
2083  0x36FC0000,
2084  0x36FE0000,
2085  0x37000000,
2086  0x37010000,
2087  0x37020000,
2088  0x37030000,
2089  0x37040000,
2090  0x37050000,
2091  0x37060000,
2092  0x37070000,
2093  0x37080000,
2094  0x37090000,
2095  0x370A0000,
2096  0x370B0000,
2097  0x370C0000,
2098  0x370D0000,
2099  0x370E0000,
2100  0x370F0000,
2101  0x37100000,
2102  0x37110000,
2103  0x37120000,
2104  0x37130000,
2105  0x37140000,
2106  0x37150000,
2107  0x37160000,
2108  0x37170000,
2109  0x37180000,
2110  0x37190000,
2111  0x371A0000,
2112  0x371B0000,
2113  0x371C0000,
2114  0x371D0000,
2115  0x371E0000,
2116  0x371F0000,
2117  0x37200000,
2118  0x37210000,
2119  0x37220000,
2120  0x37230000,
2121  0x37240000,
2122  0x37250000,
2123  0x37260000,
2124  0x37270000,
2125  0x37280000,
2126  0x37290000,
2127  0x372A0000,
2128  0x372B0000,
2129  0x372C0000,
2130  0x372D0000,
2131  0x372E0000,
2132  0x372F0000,
2133  0x37300000,
2134  0x37310000,
2135  0x37320000,
2136  0x37330000,
2137  0x37340000,
2138  0x37350000,
2139  0x37360000,
2140  0x37370000,
2141  0x37380000,
2142  0x37390000,
2143  0x373A0000,
2144  0x373B0000,
2145  0x373C0000,
2146  0x373D0000,
2147  0x373E0000,
2148  0x373F0000,
2149  0x37400000,
2150  0x37410000,
2151  0x37420000,
2152  0x37430000,
2153  0x37440000,
2154  0x37450000,
2155  0x37460000,
2156  0x37470000,
2157  0x37480000,
2158  0x37490000,
2159  0x374A0000,
2160  0x374B0000,
2161  0x374C0000,
2162  0x374D0000,
2163  0x374E0000,
2164  0x374F0000,
2165  0x37500000,
2166  0x37510000,
2167  0x37520000,
2168  0x37530000,
2169  0x37540000,
2170  0x37550000,
2171  0x37560000,
2172  0x37570000,
2173  0x37580000,
2174  0x37590000,
2175  0x375A0000,
2176  0x375B0000,
2177  0x375C0000,
2178  0x375D0000,
2179  0x375E0000,
2180  0x375F0000,
2181  0x37600000,
2182  0x37610000,
2183  0x37620000,
2184  0x37630000,
2185  0x37640000,
2186  0x37650000,
2187  0x37660000,
2188  0x37670000,
2189  0x37680000,
2190  0x37690000,
2191  0x376A0000,
2192  0x376B0000,
2193  0x376C0000,
2194  0x376D0000,
2195  0x376E0000,
2196  0x376F0000,
2197  0x37700000,
2198  0x37710000,
2199  0x37720000,
2200  0x37730000,
2201  0x37740000,
2202  0x37750000,
2203  0x37760000,
2204  0x37770000,
2205  0x37780000,
2206  0x37790000,
2207  0x377A0000,
2208  0x377B0000,
2209  0x377C0000,
2210  0x377D0000,
2211  0x377E0000,
2212  0x377F0000,
2213  0x37800000,
2214  0x37808000,
2215  0x37810000,
2216  0x37818000,
2217  0x37820000,
2218  0x37828000,
2219  0x37830000,
2220  0x37838000,
2221  0x37840000,
2222  0x37848000,
2223  0x37850000,
2224  0x37858000,
2225  0x37860000,
2226  0x37868000,
2227  0x37870000,
2228  0x37878000,
2229  0x37880000,
2230  0x37888000,
2231  0x37890000,
2232  0x37898000,
2233  0x378A0000,
2234  0x378A8000,
2235  0x378B0000,
2236  0x378B8000,
2237  0x378C0000,
2238  0x378C8000,
2239  0x378D0000,
2240  0x378D8000,
2241  0x378E0000,
2242  0x378E8000,
2243  0x378F0000,
2244  0x378F8000,
2245  0x37900000,
2246  0x37908000,
2247  0x37910000,
2248  0x37918000,
2249  0x37920000,
2250  0x37928000,
2251  0x37930000,
2252  0x37938000,
2253  0x37940000,
2254  0x37948000,
2255  0x37950000,
2256  0x37958000,
2257  0x37960000,
2258  0x37968000,
2259  0x37970000,
2260  0x37978000,
2261  0x37980000,
2262  0x37988000,
2263  0x37990000,
2264  0x37998000,
2265  0x379A0000,
2266  0x379A8000,
2267  0x379B0000,
2268  0x379B8000,
2269  0x379C0000,
2270  0x379C8000,
2271  0x379D0000,
2272  0x379D8000,
2273  0x379E0000,
2274  0x379E8000,
2275  0x379F0000,
2276  0x379F8000,
2277  0x37A00000,
2278  0x37A08000,
2279  0x37A10000,
2280  0x37A18000,
2281  0x37A20000,
2282  0x37A28000,
2283  0x37A30000,
2284  0x37A38000,
2285  0x37A40000,
2286  0x37A48000,
2287  0x37A50000,
2288  0x37A58000,
2289  0x37A60000,
2290  0x37A68000,
2291  0x37A70000,
2292  0x37A78000,
2293  0x37A80000,
2294  0x37A88000,
2295  0x37A90000,
2296  0x37A98000,
2297  0x37AA0000,
2298  0x37AA8000,
2299  0x37AB0000,
2300  0x37AB8000,
2301  0x37AC0000,
2302  0x37AC8000,
2303  0x37AD0000,
2304  0x37AD8000,
2305  0x37AE0000,
2306  0x37AE8000,
2307  0x37AF0000,
2308  0x37AF8000,
2309  0x37B00000,
2310  0x37B08000,
2311  0x37B10000,
2312  0x37B18000,
2313  0x37B20000,
2314  0x37B28000,
2315  0x37B30000,
2316  0x37B38000,
2317  0x37B40000,
2318  0x37B48000,
2319  0x37B50000,
2320  0x37B58000,
2321  0x37B60000,
2322  0x37B68000,
2323  0x37B70000,
2324  0x37B78000,
2325  0x37B80000,
2326  0x37B88000,
2327  0x37B90000,
2328  0x37B98000,
2329  0x37BA0000,
2330  0x37BA8000,
2331  0x37BB0000,
2332  0x37BB8000,
2333  0x37BC0000,
2334  0x37BC8000,
2335  0x37BD0000,
2336  0x37BD8000,
2337  0x37BE0000,
2338  0x37BE8000,
2339  0x37BF0000,
2340  0x37BF8000,
2341  0x37C00000,
2342  0x37C08000,
2343  0x37C10000,
2344  0x37C18000,
2345  0x37C20000,
2346  0x37C28000,
2347  0x37C30000,
2348  0x37C38000,
2349  0x37C40000,
2350  0x37C48000,
2351  0x37C50000,
2352  0x37C58000,
2353  0x37C60000,
2354  0x37C68000,
2355  0x37C70000,
2356  0x37C78000,
2357  0x37C80000,
2358  0x37C88000,
2359  0x37C90000,
2360  0x37C98000,
2361  0x37CA0000,
2362  0x37CA8000,
2363  0x37CB0000,
2364  0x37CB8000,
2365  0x37CC0000,
2366  0x37CC8000,
2367  0x37CD0000,
2368  0x37CD8000,
2369  0x37CE0000,
2370  0x37CE8000,
2371  0x37CF0000,
2372  0x37CF8000,
2373  0x37D00000,
2374  0x37D08000,
2375  0x37D10000,
2376  0x37D18000,
2377  0x37D20000,
2378  0x37D28000,
2379  0x37D30000,
2380  0x37D38000,
2381  0x37D40000,
2382  0x37D48000,
2383  0x37D50000,
2384  0x37D58000,
2385  0x37D60000,
2386  0x37D68000,
2387  0x37D70000,
2388  0x37D78000,
2389  0x37D80000,
2390  0x37D88000,
2391  0x37D90000,
2392  0x37D98000,
2393  0x37DA0000,
2394  0x37DA8000,
2395  0x37DB0000,
2396  0x37DB8000,
2397  0x37DC0000,
2398  0x37DC8000,
2399  0x37DD0000,
2400  0x37DD8000,
2401  0x37DE0000,
2402  0x37DE8000,
2403  0x37DF0000,
2404  0x37DF8000,
2405  0x37E00000,
2406  0x37E08000,
2407  0x37E10000,
2408  0x37E18000,
2409  0x37E20000,
2410  0x37E28000,
2411  0x37E30000,
2412  0x37E38000,
2413  0x37E40000,
2414  0x37E48000,
2415  0x37E50000,
2416  0x37E58000,
2417  0x37E60000,
2418  0x37E68000,
2419  0x37E70000,
2420  0x37E78000,
2421  0x37E80000,
2422  0x37E88000,
2423  0x37E90000,
2424  0x37E98000,
2425  0x37EA0000,
2426  0x37EA8000,
2427  0x37EB0000,
2428  0x37EB8000,
2429  0x37EC0000,
2430  0x37EC8000,
2431  0x37ED0000,
2432  0x37ED8000,
2433  0x37EE0000,
2434  0x37EE8000,
2435  0x37EF0000,
2436  0x37EF8000,
2437  0x37F00000,
2438  0x37F08000,
2439  0x37F10000,
2440  0x37F18000,
2441  0x37F20000,
2442  0x37F28000,
2443  0x37F30000,
2444  0x37F38000,
2445  0x37F40000,
2446  0x37F48000,
2447  0x37F50000,
2448  0x37F58000,
2449  0x37F60000,
2450  0x37F68000,
2451  0x37F70000,
2452  0x37F78000,
2453  0x37F80000,
2454  0x37F88000,
2455  0x37F90000,
2456  0x37F98000,
2457  0x37FA0000,
2458  0x37FA8000,
2459  0x37FB0000,
2460  0x37FB8000,
2461  0x37FC0000,
2462  0x37FC8000,
2463  0x37FD0000,
2464  0x37FD8000,
2465  0x37FE0000,
2466  0x37FE8000,
2467  0x37FF0000,
2468  0x37FF8000,
2469  0x38000000,
2470  0x38004000,
2471  0x38008000,
2472  0x3800C000,
2473  0x38010000,
2474  0x38014000,
2475  0x38018000,
2476  0x3801C000,
2477  0x38020000,
2478  0x38024000,
2479  0x38028000,
2480  0x3802C000,
2481  0x38030000,
2482  0x38034000,
2483  0x38038000,
2484  0x3803C000,
2485  0x38040000,
2486  0x38044000,
2487  0x38048000,
2488  0x3804C000,
2489  0x38050000,
2490  0x38054000,
2491  0x38058000,
2492  0x3805C000,
2493  0x38060000,
2494  0x38064000,
2495  0x38068000,
2496  0x3806C000,
2497  0x38070000,
2498  0x38074000,
2499  0x38078000,
2500  0x3807C000,
2501  0x38080000,
2502  0x38084000,
2503  0x38088000,
2504  0x3808C000,
2505  0x38090000,
2506  0x38094000,
2507  0x38098000,
2508  0x3809C000,
2509  0x380A0000,
2510  0x380A4000,
2511  0x380A8000,
2512  0x380AC000,
2513  0x380B0000,
2514  0x380B4000,
2515  0x380B8000,
2516  0x380BC000,
2517  0x380C0000,
2518  0x380C4000,
2519  0x380C8000,
2520  0x380CC000,
2521  0x380D0000,
2522  0x380D4000,
2523  0x380D8000,
2524  0x380DC000,
2525  0x380E0000,
2526  0x380E4000,
2527  0x380E8000,
2528  0x380EC000,
2529  0x380F0000,
2530  0x380F4000,
2531  0x380F8000,
2532  0x380FC000,
2533  0x38100000,
2534  0x38104000,
2535  0x38108000,
2536  0x3810C000,
2537  0x38110000,
2538  0x38114000,
2539  0x38118000,
2540  0x3811C000,
2541  0x38120000,
2542  0x38124000,
2543  0x38128000,
2544  0x3812C000,
2545  0x38130000,
2546  0x38134000,
2547  0x38138000,
2548  0x3813C000,
2549  0x38140000,
2550  0x38144000,
2551  0x38148000,
2552  0x3814C000,
2553  0x38150000,
2554  0x38154000,
2555  0x38158000,
2556  0x3815C000,
2557  0x38160000,
2558  0x38164000,
2559  0x38168000,
2560  0x3816C000,
2561  0x38170000,
2562  0x38174000,
2563  0x38178000,
2564  0x3817C000,
2565  0x38180000,
2566  0x38184000,
2567  0x38188000,
2568  0x3818C000,
2569  0x38190000,
2570  0x38194000,
2571  0x38198000,
2572  0x3819C000,
2573  0x381A0000,
2574  0x381A4000,
2575  0x381A8000,
2576  0x381AC000,
2577  0x381B0000,
2578  0x381B4000,
2579  0x381B8000,
2580  0x381BC000,
2581  0x381C0000,
2582  0x381C4000,
2583  0x381C8000,
2584  0x381CC000,
2585  0x381D0000,
2586  0x381D4000,
2587  0x381D8000,
2588  0x381DC000,
2589  0x381E0000,
2590  0x381E4000,
2591  0x381E8000,
2592  0x381EC000,
2593  0x381F0000,
2594  0x381F4000,
2595  0x381F8000,
2596  0x381FC000,
2597  0x38200000,
2598  0x38204000,
2599  0x38208000,
2600  0x3820C000,
2601  0x38210000,
2602  0x38214000,
2603  0x38218000,
2604  0x3821C000,
2605  0x38220000,
2606  0x38224000,
2607  0x38228000,
2608  0x3822C000,
2609  0x38230000,
2610  0x38234000,
2611  0x38238000,
2612  0x3823C000,
2613  0x38240000,
2614  0x38244000,
2615  0x38248000,
2616  0x3824C000,
2617  0x38250000,
2618  0x38254000,
2619  0x38258000,
2620  0x3825C000,
2621  0x38260000,
2622  0x38264000,
2623  0x38268000,
2624  0x3826C000,
2625  0x38270000,
2626  0x38274000,
2627  0x38278000,
2628  0x3827C000,
2629  0x38280000,
2630  0x38284000,
2631  0x38288000,
2632  0x3828C000,
2633  0x38290000,
2634  0x38294000,
2635  0x38298000,
2636  0x3829C000,
2637  0x382A0000,
2638  0x382A4000,
2639  0x382A8000,
2640  0x382AC000,
2641  0x382B0000,
2642  0x382B4000,
2643  0x382B8000,
2644  0x382BC000,
2645  0x382C0000,
2646  0x382C4000,
2647  0x382C8000,
2648  0x382CC000,
2649  0x382D0000,
2650  0x382D4000,
2651  0x382D8000,
2652  0x382DC000,
2653  0x382E0000,
2654  0x382E4000,
2655  0x382E8000,
2656  0x382EC000,
2657  0x382F0000,
2658  0x382F4000,
2659  0x382F8000,
2660  0x382FC000,
2661  0x38300000,
2662  0x38304000,
2663  0x38308000,
2664  0x3830C000,
2665  0x38310000,
2666  0x38314000,
2667  0x38318000,
2668  0x3831C000,
2669  0x38320000,
2670  0x38324000,
2671  0x38328000,
2672  0x3832C000,
2673  0x38330000,
2674  0x38334000,
2675  0x38338000,
2676  0x3833C000,
2677  0x38340000,
2678  0x38344000,
2679  0x38348000,
2680  0x3834C000,
2681  0x38350000,
2682  0x38354000,
2683  0x38358000,
2684  0x3835C000,
2685  0x38360000,
2686  0x38364000,
2687  0x38368000,
2688  0x3836C000,
2689  0x38370000,
2690  0x38374000,
2691  0x38378000,
2692  0x3837C000,
2693  0x38380000,
2694  0x38384000,
2695  0x38388000,
2696  0x3838C000,
2697  0x38390000,
2698  0x38394000,
2699  0x38398000,
2700  0x3839C000,
2701  0x383A0000,
2702  0x383A4000,
2703  0x383A8000,
2704  0x383AC000,
2705  0x383B0000,
2706  0x383B4000,
2707  0x383B8000,
2708  0x383BC000,
2709  0x383C0000,
2710  0x383C4000,
2711  0x383C8000,
2712  0x383CC000,
2713  0x383D0000,
2714  0x383D4000,
2715  0x383D8000,
2716  0x383DC000,
2717  0x383E0000,
2718  0x383E4000,
2719  0x383E8000,
2720  0x383EC000,
2721  0x383F0000,
2722  0x383F4000,
2723  0x383F8000,
2724  0x383FC000,
2725  0x38400000,
2726  0x38404000,
2727  0x38408000,
2728  0x3840C000,
2729  0x38410000,
2730  0x38414000,
2731  0x38418000,
2732  0x3841C000,
2733  0x38420000,
2734  0x38424000,
2735  0x38428000,
2736  0x3842C000,
2737  0x38430000,
2738  0x38434000,
2739  0x38438000,
2740  0x3843C000,
2741  0x38440000,
2742  0x38444000,
2743  0x38448000,
2744  0x3844C000,
2745  0x38450000,
2746  0x38454000,
2747  0x38458000,
2748  0x3845C000,
2749  0x38460000,
2750  0x38464000,
2751  0x38468000,
2752  0x3846C000,
2753  0x38470000,
2754  0x38474000,
2755  0x38478000,
2756  0x3847C000,
2757  0x38480000,
2758  0x38484000,
2759  0x38488000,
2760  0x3848C000,
2761  0x38490000,
2762  0x38494000,
2763  0x38498000,
2764  0x3849C000,
2765  0x384A0000,
2766  0x384A4000,
2767  0x384A8000,
2768  0x384AC000,
2769  0x384B0000,
2770  0x384B4000,
2771  0x384B8000,
2772  0x384BC000,
2773  0x384C0000,
2774  0x384C4000,
2775  0x384C8000,
2776  0x384CC000,
2777  0x384D0000,
2778  0x384D4000,
2779  0x384D8000,
2780  0x384DC000,
2781  0x384E0000,
2782  0x384E4000,
2783  0x384E8000,
2784  0x384EC000,
2785  0x384F0000,
2786  0x384F4000,
2787  0x384F8000,
2788  0x384FC000,
2789  0x38500000,
2790  0x38504000,
2791  0x38508000,
2792  0x3850C000,
2793  0x38510000,
2794  0x38514000,
2795  0x38518000,
2796  0x3851C000,
2797  0x38520000,
2798  0x38524000,
2799  0x38528000,
2800  0x3852C000,
2801  0x38530000,
2802  0x38534000,
2803  0x38538000,
2804  0x3853C000,
2805  0x38540000,
2806  0x38544000,
2807  0x38548000,
2808  0x3854C000,
2809  0x38550000,
2810  0x38554000,
2811  0x38558000,
2812  0x3855C000,
2813  0x38560000,
2814  0x38564000,
2815  0x38568000,
2816  0x3856C000,
2817  0x38570000,
2818  0x38574000,
2819  0x38578000,
2820  0x3857C000,
2821  0x38580000,
2822  0x38584000,
2823  0x38588000,
2824  0x3858C000,
2825  0x38590000,
2826  0x38594000,
2827  0x38598000,
2828  0x3859C000,
2829  0x385A0000,
2830  0x385A4000,
2831  0x385A8000,
2832  0x385AC000,
2833  0x385B0000,
2834  0x385B4000,
2835  0x385B8000,
2836  0x385BC000,
2837  0x385C0000,
2838  0x385C4000,
2839  0x385C8000,
2840  0x385CC000,
2841  0x385D0000,
2842  0x385D4000,
2843  0x385D8000,
2844  0x385DC000,
2845  0x385E0000,
2846  0x385E4000,
2847  0x385E8000,
2848  0x385EC000,
2849  0x385F0000,
2850  0x385F4000,
2851  0x385F8000,
2852  0x385FC000,
2853  0x38600000,
2854  0x38604000,
2855  0x38608000,
2856  0x3860C000,
2857  0x38610000,
2858  0x38614000,
2859  0x38618000,
2860  0x3861C000,
2861  0x38620000,
2862  0x38624000,
2863  0x38628000,
2864  0x3862C000,
2865  0x38630000,
2866  0x38634000,
2867  0x38638000,
2868  0x3863C000,
2869  0x38640000,
2870  0x38644000,
2871  0x38648000,
2872  0x3864C000,
2873  0x38650000,
2874  0x38654000,
2875  0x38658000,
2876  0x3865C000,
2877  0x38660000,
2878  0x38664000,
2879  0x38668000,
2880  0x3866C000,
2881  0x38670000,
2882  0x38674000,
2883  0x38678000,
2884  0x3867C000,
2885  0x38680000,
2886  0x38684000,
2887  0x38688000,
2888  0x3868C000,
2889  0x38690000,
2890  0x38694000,
2891  0x38698000,
2892  0x3869C000,
2893  0x386A0000,
2894  0x386A4000,
2895  0x386A8000,
2896  0x386AC000,
2897  0x386B0000,
2898  0x386B4000,
2899  0x386B8000,
2900  0x386BC000,
2901  0x386C0000,
2902  0x386C4000,
2903  0x386C8000,
2904  0x386CC000,
2905  0x386D0000,
2906  0x386D4000,
2907  0x386D8000,
2908  0x386DC000,
2909  0x386E0000,
2910  0x386E4000,
2911  0x386E8000,
2912  0x386EC000,
2913  0x386F0000,
2914  0x386F4000,
2915  0x386F8000,
2916  0x386FC000,
2917  0x38700000,
2918  0x38704000,
2919  0x38708000,
2920  0x3870C000,
2921  0x38710000,
2922  0x38714000,
2923  0x38718000,
2924  0x3871C000,
2925  0x38720000,
2926  0x38724000,
2927  0x38728000,
2928  0x3872C000,
2929  0x38730000,
2930  0x38734000,
2931  0x38738000,
2932  0x3873C000,
2933  0x38740000,
2934  0x38744000,
2935  0x38748000,
2936  0x3874C000,
2937  0x38750000,
2938  0x38754000,
2939  0x38758000,
2940  0x3875C000,
2941  0x38760000,
2942  0x38764000,
2943  0x38768000,
2944  0x3876C000,
2945  0x38770000,
2946  0x38774000,
2947  0x38778000,
2948  0x3877C000,
2949  0x38780000,
2950  0x38784000,
2951  0x38788000,
2952  0x3878C000,
2953  0x38790000,
2954  0x38794000,
2955  0x38798000,
2956  0x3879C000,
2957  0x387A0000,
2958  0x387A4000,
2959  0x387A8000,
2960  0x387AC000,
2961  0x387B0000,
2962  0x387B4000,
2963  0x387B8000,
2964  0x387BC000,
2965  0x387C0000,
2966  0x387C4000,
2967  0x387C8000,
2968  0x387CC000,
2969  0x387D0000,
2970  0x387D4000,
2971  0x387D8000,
2972  0x387DC000,
2973  0x387E0000,
2974  0x387E4000,
2975  0x387E8000,
2976  0x387EC000,
2977  0x387F0000,
2978  0x387F4000,
2979  0x387F8000,
2980  0x387FC000,
2981  0x38000000,
2982  0x38002000,
2983  0x38004000,
2984  0x38006000,
2985  0x38008000,
2986  0x3800A000,
2987  0x3800C000,
2988  0x3800E000,
2989  0x38010000,
2990  0x38012000,
2991  0x38014000,
2992  0x38016000,
2993  0x38018000,
2994  0x3801A000,
2995  0x3801C000,
2996  0x3801E000,
2997  0x38020000,
2998  0x38022000,
2999  0x38024000,
3000  0x38026000,
3001  0x38028000,
3002  0x3802A000,
3003  0x3802C000,
3004  0x3802E000,
3005  0x38030000,
3006  0x38032000,
3007  0x38034000,
3008  0x38036000,
3009  0x38038000,
3010  0x3803A000,
3011  0x3803C000,
3012  0x3803E000,
3013  0x38040000,
3014  0x38042000,
3015  0x38044000,
3016  0x38046000,
3017  0x38048000,
3018  0x3804A000,
3019  0x3804C000,
3020  0x3804E000,
3021  0x38050000,
3022  0x38052000,
3023  0x38054000,
3024  0x38056000,
3025  0x38058000,
3026  0x3805A000,
3027  0x3805C000,
3028  0x3805E000,
3029  0x38060000,
3030  0x38062000,
3031  0x38064000,
3032  0x38066000,
3033  0x38068000,
3034  0x3806A000,
3035  0x3806C000,
3036  0x3806E000,
3037  0x38070000,
3038  0x38072000,
3039  0x38074000,
3040  0x38076000,
3041  0x38078000,
3042  0x3807A000,
3043  0x3807C000,
3044  0x3807E000,
3045  0x38080000,
3046  0x38082000,
3047  0x38084000,
3048  0x38086000,
3049  0x38088000,
3050  0x3808A000,
3051  0x3808C000,
3052  0x3808E000,
3053  0x38090000,
3054  0x38092000,
3055  0x38094000,
3056  0x38096000,
3057  0x38098000,
3058  0x3809A000,
3059  0x3809C000,
3060  0x3809E000,
3061  0x380A0000,
3062  0x380A2000,
3063  0x380A4000,
3064  0x380A6000,
3065  0x380A8000,
3066  0x380AA000,
3067  0x380AC000,
3068  0x380AE000,
3069  0x380B0000,
3070  0x380B2000,
3071  0x380B4000,
3072  0x380B6000,
3073  0x380B8000,
3074  0x380BA000,
3075  0x380BC000,
3076  0x380BE000,
3077  0x380C0000,
3078  0x380C2000,
3079  0x380C4000,
3080  0x380C6000,
3081  0x380C8000,
3082  0x380CA000,
3083  0x380CC000,
3084  0x380CE000,
3085  0x380D0000,
3086  0x380D2000,
3087  0x380D4000,
3088  0x380D6000,
3089  0x380D8000,
3090  0x380DA000,
3091  0x380DC000,
3092  0x380DE000,
3093  0x380E0000,
3094  0x380E2000,
3095  0x380E4000,
3096  0x380E6000,
3097  0x380E8000,
3098  0x380EA000,
3099  0x380EC000,
3100  0x380EE000,
3101  0x380F0000,
3102  0x380F2000,
3103  0x380F4000,
3104  0x380F6000,
3105  0x380F8000,
3106  0x380FA000,
3107  0x380FC000,
3108  0x380FE000,
3109  0x38100000,
3110  0x38102000,
3111  0x38104000,
3112  0x38106000,
3113  0x38108000,
3114  0x3810A000,
3115  0x3810C000,
3116  0x3810E000,
3117  0x38110000,
3118  0x38112000,
3119  0x38114000,
3120  0x38116000,
3121  0x38118000,
3122  0x3811A000,
3123  0x3811C000,
3124  0x3811E000,
3125  0x38120000,
3126  0x38122000,
3127  0x38124000,
3128  0x38126000,
3129  0x38128000,
3130  0x3812A000,
3131  0x3812C000,
3132  0x3812E000,
3133  0x38130000,
3134  0x38132000,
3135  0x38134000,
3136  0x38136000,
3137  0x38138000,
3138  0x3813A000,
3139  0x3813C000,
3140  0x3813E000,
3141  0x38140000,
3142  0x38142000,
3143  0x38144000,
3144  0x38146000,
3145  0x38148000,
3146  0x3814A000,
3147  0x3814C000,
3148  0x3814E000,
3149  0x38150000,
3150  0x38152000,
3151  0x38154000,
3152  0x38156000,
3153  0x38158000,
3154  0x3815A000,
3155  0x3815C000,
3156  0x3815E000,
3157  0x38160000,
3158  0x38162000,
3159  0x38164000,
3160  0x38166000,
3161  0x38168000,
3162  0x3816A000,
3163  0x3816C000,
3164  0x3816E000,
3165  0x38170000,
3166  0x38172000,
3167  0x38174000,
3168  0x38176000,
3169  0x38178000,
3170  0x3817A000,
3171  0x3817C000,
3172  0x3817E000,
3173  0x38180000,
3174  0x38182000,
3175  0x38184000,
3176  0x38186000,
3177  0x38188000,
3178  0x3818A000,
3179  0x3818C000,
3180  0x3818E000,
3181  0x38190000,
3182  0x38192000,
3183  0x38194000,
3184  0x38196000,
3185  0x38198000,
3186  0x3819A000,
3187  0x3819C000,
3188  0x3819E000,
3189  0x381A0000,
3190  0x381A2000,
3191  0x381A4000,
3192  0x381A6000,
3193  0x381A8000,
3194  0x381AA000,
3195  0x381AC000,
3196  0x381AE000,
3197  0x381B0000,
3198  0x381B2000,
3199  0x381B4000,
3200  0x381B6000,
3201  0x381B8000,
3202  0x381BA000,
3203  0x381BC000,
3204  0x381BE000,
3205  0x381C0000,
3206  0x381C2000,
3207  0x381C4000,
3208  0x381C6000,
3209  0x381C8000,
3210  0x381CA000,
3211  0x381CC000,
3212  0x381CE000,
3213  0x381D0000,
3214  0x381D2000,
3215  0x381D4000,
3216  0x381D6000,
3217  0x381D8000,
3218  0x381DA000,
3219  0x381DC000,
3220  0x381DE000,
3221  0x381E0000,
3222  0x381E2000,
3223  0x381E4000,
3224  0x381E6000,
3225  0x381E8000,
3226  0x381EA000,
3227  0x381EC000,
3228  0x381EE000,
3229  0x381F0000,
3230  0x381F2000,
3231  0x381F4000,
3232  0x381F6000,
3233  0x381F8000,
3234  0x381FA000,
3235  0x381FC000,
3236  0x381FE000,
3237  0x38200000,
3238  0x38202000,
3239  0x38204000,
3240  0x38206000,
3241  0x38208000,
3242  0x3820A000,
3243  0x3820C000,
3244  0x3820E000,
3245  0x38210000,
3246  0x38212000,
3247  0x38214000,
3248  0x38216000,
3249  0x38218000,
3250  0x3821A000,
3251  0x3821C000,
3252  0x3821E000,
3253  0x38220000,
3254  0x38222000,
3255  0x38224000,
3256  0x38226000,
3257  0x38228000,
3258  0x3822A000,
3259  0x3822C000,
3260  0x3822E000,
3261  0x38230000,
3262  0x38232000,
3263  0x38234000,
3264  0x38236000,
3265  0x38238000,
3266  0x3823A000,
3267  0x3823C000,
3268  0x3823E000,
3269  0x38240000,
3270  0x38242000,
3271  0x38244000,
3272  0x38246000,
3273  0x38248000,
3274  0x3824A000,
3275  0x3824C000,
3276  0x3824E000,
3277  0x38250000,
3278  0x38252000,
3279  0x38254000,
3280  0x38256000,
3281  0x38258000,
3282  0x3825A000,
3283  0x3825C000,
3284  0x3825E000,
3285  0x38260000,
3286  0x38262000,
3287  0x38264000,
3288  0x38266000,
3289  0x38268000,
3290  0x3826A000,
3291  0x3826C000,
3292  0x3826E000,
3293  0x38270000,
3294  0x38272000,
3295  0x38274000,
3296  0x38276000,
3297  0x38278000,
3298  0x3827A000,
3299  0x3827C000,
3300  0x3827E000,
3301  0x38280000,
3302  0x38282000,
3303  0x38284000,
3304  0x38286000,
3305  0x38288000,
3306  0x3828A000,
3307  0x3828C000,
3308  0x3828E000,
3309  0x38290000,
3310  0x38292000,
3311  0x38294000,
3312  0x38296000,
3313  0x38298000,
3314  0x3829A000,
3315  0x3829C000,
3316  0x3829E000,
3317  0x382A0000,
3318  0x382A2000,
3319  0x382A4000,
3320  0x382A6000,
3321  0x382A8000,
3322  0x382AA000,
3323  0x382AC000,
3324  0x382AE000,
3325  0x382B0000,
3326  0x382B2000,
3327  0x382B4000,
3328  0x382B6000,
3329  0x382B8000,
3330  0x382BA000,
3331  0x382BC000,
3332  0x382BE000,
3333  0x382C0000,
3334  0x382C2000,
3335  0x382C4000,
3336  0x382C6000,
3337  0x382C8000,
3338  0x382CA000,
3339  0x382CC000,
3340  0x382CE000,
3341  0x382D0000,
3342  0x382D2000,
3343  0x382D4000,
3344  0x382D6000,
3345  0x382D8000,
3346  0x382DA000,
3347  0x382DC000,
3348  0x382DE000,
3349  0x382E0000,
3350  0x382E2000,
3351  0x382E4000,
3352  0x382E6000,
3353  0x382E8000,
3354  0x382EA000,
3355  0x382EC000,
3356  0x382EE000,
3357  0x382F0000,
3358  0x382F2000,
3359  0x382F4000,
3360  0x382F6000,
3361  0x382F8000,
3362  0x382FA000,
3363  0x382FC000,
3364  0x382FE000,
3365  0x38300000,
3366  0x38302000,
3367  0x38304000,
3368  0x38306000,
3369  0x38308000,
3370  0x3830A000,
3371  0x3830C000,
3372  0x3830E000,
3373  0x38310000,
3374  0x38312000,
3375  0x38314000,
3376  0x38316000,
3377  0x38318000,
3378  0x3831A000,
3379  0x3831C000,
3380  0x3831E000,
3381  0x38320000,
3382  0x38322000,
3383  0x38324000,
3384  0x38326000,
3385  0x38328000,
3386  0x3832A000,
3387  0x3832C000,
3388  0x3832E000,
3389  0x38330000,
3390  0x38332000,
3391  0x38334000,
3392  0x38336000,
3393  0x38338000,
3394  0x3833A000,
3395  0x3833C000,
3396  0x3833E000,
3397  0x38340000,
3398  0x38342000,
3399  0x38344000,
3400  0x38346000,
3401  0x38348000,
3402  0x3834A000,
3403  0x3834C000,
3404  0x3834E000,
3405  0x38350000,
3406  0x38352000,
3407  0x38354000,
3408  0x38356000,
3409  0x38358000,
3410  0x3835A000,
3411  0x3835C000,
3412  0x3835E000,
3413  0x38360000,
3414  0x38362000,
3415  0x38364000,
3416  0x38366000,
3417  0x38368000,
3418  0x3836A000,
3419  0x3836C000,
3420  0x3836E000,
3421  0x38370000,
3422  0x38372000,
3423  0x38374000,
3424  0x38376000,
3425  0x38378000,
3426  0x3837A000,
3427  0x3837C000,
3428  0x3837E000,
3429  0x38380000,
3430  0x38382000,
3431  0x38384000,
3432  0x38386000,
3433  0x38388000,
3434  0x3838A000,
3435  0x3838C000,
3436  0x3838E000,
3437  0x38390000,
3438  0x38392000,
3439  0x38394000,
3440  0x38396000,
3441  0x38398000,
3442  0x3839A000,
3443  0x3839C000,
3444  0x3839E000,
3445  0x383A0000,
3446  0x383A2000,
3447  0x383A4000,
3448  0x383A6000,
3449  0x383A8000,
3450  0x383AA000,
3451  0x383AC000,
3452  0x383AE000,
3453  0x383B0000,
3454  0x383B2000,
3455  0x383B4000,
3456  0x383B6000,
3457  0x383B8000,
3458  0x383BA000,
3459  0x383BC000,
3460  0x383BE000,
3461  0x383C0000,
3462  0x383C2000,
3463  0x383C4000,
3464  0x383C6000,
3465  0x383C8000,
3466  0x383CA000,
3467  0x383CC000,
3468  0x383CE000,
3469  0x383D0000,
3470  0x383D2000,
3471  0x383D4000,
3472  0x383D6000,
3473  0x383D8000,
3474  0x383DA000,
3475  0x383DC000,
3476  0x383DE000,
3477  0x383E0000,
3478  0x383E2000,
3479  0x383E4000,
3480  0x383E6000,
3481  0x383E8000,
3482  0x383EA000,
3483  0x383EC000,
3484  0x383EE000,
3485  0x383F0000,
3486  0x383F2000,
3487  0x383F4000,
3488  0x383F6000,
3489  0x383F8000,
3490  0x383FA000,
3491  0x383FC000,
3492  0x383FE000,
3493  0x38400000,
3494  0x38402000,
3495  0x38404000,
3496  0x38406000,
3497  0x38408000,
3498  0x3840A000,
3499  0x3840C000,
3500  0x3840E000,
3501  0x38410000,
3502  0x38412000,
3503  0x38414000,
3504  0x38416000,
3505  0x38418000,
3506  0x3841A000,
3507  0x3841C000,
3508  0x3841E000,
3509  0x38420000,
3510  0x38422000,
3511  0x38424000,
3512  0x38426000,
3513  0x38428000,
3514  0x3842A000,
3515  0x3842C000,
3516  0x3842E000,
3517  0x38430000,
3518  0x38432000,
3519  0x38434000,
3520  0x38436000,
3521  0x38438000,
3522  0x3843A000,
3523  0x3843C000,
3524  0x3843E000,
3525  0x38440000,
3526  0x38442000,
3527  0x38444000,
3528  0x38446000,
3529  0x38448000,
3530  0x3844A000,
3531  0x3844C000,
3532  0x3844E000,
3533  0x38450000,
3534  0x38452000,
3535  0x38454000,
3536  0x38456000,
3537  0x38458000,
3538  0x3845A000,
3539  0x3845C000,
3540  0x3845E000,
3541  0x38460000,
3542  0x38462000,
3543  0x38464000,
3544  0x38466000,
3545  0x38468000,
3546  0x3846A000,
3547  0x3846C000,
3548  0x3846E000,
3549  0x38470000,
3550  0x38472000,
3551  0x38474000,
3552  0x38476000,
3553  0x38478000,
3554  0x3847A000,
3555  0x3847C000,
3556  0x3847E000,
3557  0x38480000,
3558  0x38482000,
3559  0x38484000,
3560  0x38486000,
3561  0x38488000,
3562  0x3848A000,
3563  0x3848C000,
3564  0x3848E000,
3565  0x38490000,
3566  0x38492000,
3567  0x38494000,
3568  0x38496000,
3569  0x38498000,
3570  0x3849A000,
3571  0x3849C000,
3572  0x3849E000,
3573  0x384A0000,
3574  0x384A2000,
3575  0x384A4000,
3576  0x384A6000,
3577  0x384A8000,
3578  0x384AA000,
3579  0x384AC000,
3580  0x384AE000,
3581  0x384B0000,
3582  0x384B2000,
3583  0x384B4000,
3584  0x384B6000,
3585  0x384B8000,
3586  0x384BA000,
3587  0x384BC000,
3588  0x384BE000,
3589  0x384C0000,
3590  0x384C2000,
3591  0x384C4000,
3592  0x384C6000,
3593  0x384C8000,
3594  0x384CA000,
3595  0x384CC000,
3596  0x384CE000,
3597  0x384D0000,
3598  0x384D2000,
3599  0x384D4000,
3600  0x384D6000,
3601  0x384D8000,
3602  0x384DA000,
3603  0x384DC000,
3604  0x384DE000,
3605  0x384E0000,
3606  0x384E2000,
3607  0x384E4000,
3608  0x384E6000,
3609  0x384E8000,
3610  0x384EA000,
3611  0x384EC000,
3612  0x384EE000,
3613  0x384F0000,
3614  0x384F2000,
3615  0x384F4000,
3616  0x384F6000,
3617  0x384F8000,
3618  0x384FA000,
3619  0x384FC000,
3620  0x384FE000,
3621  0x38500000,
3622  0x38502000,
3623  0x38504000,
3624  0x38506000,
3625  0x38508000,
3626  0x3850A000,
3627  0x3850C000,
3628  0x3850E000,
3629  0x38510000,
3630  0x38512000,
3631  0x38514000,
3632  0x38516000,
3633  0x38518000,
3634  0x3851A000,
3635  0x3851C000,
3636  0x3851E000,
3637  0x38520000,
3638  0x38522000,
3639  0x38524000,
3640  0x38526000,
3641  0x38528000,
3642  0x3852A000,
3643  0x3852C000,
3644  0x3852E000,
3645  0x38530000,
3646  0x38532000,
3647  0x38534000,
3648  0x38536000,
3649  0x38538000,
3650  0x3853A000,
3651  0x3853C000,
3652  0x3853E000,
3653  0x38540000,
3654  0x38542000,
3655  0x38544000,
3656  0x38546000,
3657  0x38548000,
3658  0x3854A000,
3659  0x3854C000,
3660  0x3854E000,
3661  0x38550000,
3662  0x38552000,
3663  0x38554000,
3664  0x38556000,
3665  0x38558000,
3666  0x3855A000,
3667  0x3855C000,
3668  0x3855E000,
3669  0x38560000,
3670  0x38562000,
3671  0x38564000,
3672  0x38566000,
3673  0x38568000,
3674  0x3856A000,
3675  0x3856C000,
3676  0x3856E000,
3677  0x38570000,
3678  0x38572000,
3679  0x38574000,
3680  0x38576000,
3681  0x38578000,
3682  0x3857A000,
3683  0x3857C000,
3684  0x3857E000,
3685  0x38580000,
3686  0x38582000,
3687  0x38584000,
3688  0x38586000,
3689  0x38588000,
3690  0x3858A000,
3691  0x3858C000,
3692  0x3858E000,
3693  0x38590000,
3694  0x38592000,
3695  0x38594000,
3696  0x38596000,
3697  0x38598000,
3698  0x3859A000,
3699  0x3859C000,
3700  0x3859E000,
3701  0x385A0000,
3702  0x385A2000,
3703  0x385A4000,
3704  0x385A6000,
3705  0x385A8000,
3706  0x385AA000,
3707  0x385AC000,
3708  0x385AE000,
3709  0x385B0000,
3710  0x385B2000,
3711  0x385B4000,
3712  0x385B6000,
3713  0x385B8000,
3714  0x385BA000,
3715  0x385BC000,
3716  0x385BE000,
3717  0x385C0000,
3718  0x385C2000,
3719  0x385C4000,
3720  0x385C6000,
3721  0x385C8000,
3722  0x385CA000,
3723  0x385CC000,
3724  0x385CE000,
3725  0x385D0000,
3726  0x385D2000,
3727  0x385D4000,
3728  0x385D6000,
3729  0x385D8000,
3730  0x385DA000,
3731  0x385DC000,
3732  0x385DE000,
3733  0x385E0000,
3734  0x385E2000,
3735  0x385E4000,
3736  0x385E6000,
3737  0x385E8000,
3738  0x385EA000,
3739  0x385EC000,
3740  0x385EE000,
3741  0x385F0000,
3742  0x385F2000,
3743  0x385F4000,
3744  0x385F6000,
3745  0x385F8000,
3746  0x385FA000,
3747  0x385FC000,
3748  0x385FE000,
3749  0x38600000,
3750  0x38602000,
3751  0x38604000,
3752  0x38606000,
3753  0x38608000,
3754  0x3860A000,
3755  0x3860C000,
3756  0x3860E000,
3757  0x38610000,
3758  0x38612000,
3759  0x38614000,
3760  0x38616000,
3761  0x38618000,
3762  0x3861A000,
3763  0x3861C000,
3764  0x3861E000,
3765  0x38620000,
3766  0x38622000,
3767  0x38624000,
3768  0x38626000,
3769  0x38628000,
3770  0x3862A000,
3771  0x3862C000,
3772  0x3862E000,
3773  0x38630000,
3774  0x38632000,
3775  0x38634000,
3776  0x38636000,
3777  0x38638000,
3778  0x3863A000,
3779  0x3863C000,
3780  0x3863E000,
3781  0x38640000,
3782  0x38642000,
3783  0x38644000,
3784  0x38646000,
3785  0x38648000,
3786  0x3864A000,
3787  0x3864C000,
3788  0x3864E000,
3789  0x38650000,
3790  0x38652000,
3791  0x38654000,
3792  0x38656000,
3793  0x38658000,
3794  0x3865A000,
3795  0x3865C000,
3796  0x3865E000,
3797  0x38660000,
3798  0x38662000,
3799  0x38664000,
3800  0x38666000,
3801  0x38668000,
3802  0x3866A000,
3803  0x3866C000,
3804  0x3866E000,
3805  0x38670000,
3806  0x38672000,
3807  0x38674000,
3808  0x38676000,
3809  0x38678000,
3810  0x3867A000,
3811  0x3867C000,
3812  0x3867E000,
3813  0x38680000,
3814  0x38682000,
3815  0x38684000,
3816  0x38686000,
3817  0x38688000,
3818  0x3868A000,
3819  0x3868C000,
3820  0x3868E000,
3821  0x38690000,
3822  0x38692000,
3823  0x38694000,
3824  0x38696000,
3825  0x38698000,
3826  0x3869A000,
3827  0x3869C000,
3828  0x3869E000,
3829  0x386A0000,
3830  0x386A2000,
3831  0x386A4000,
3832  0x386A6000,
3833  0x386A8000,
3834  0x386AA000,
3835  0x386AC000,
3836  0x386AE000,
3837  0x386B0000,
3838  0x386B2000,
3839  0x386B4000,
3840  0x386B6000,
3841  0x386B8000,
3842  0x386BA000,
3843  0x386BC000,
3844  0x386BE000,
3845  0x386C0000,
3846  0x386C2000,
3847  0x386C4000,
3848  0x386C6000,
3849  0x386C8000,
3850  0x386CA000,
3851  0x386CC000,
3852  0x386CE000,
3853  0x386D0000,
3854  0x386D2000,
3855  0x386D4000,
3856  0x386D6000,
3857  0x386D8000,
3858  0x386DA000,
3859  0x386DC000,
3860  0x386DE000,
3861  0x386E0000,
3862  0x386E2000,
3863  0x386E4000,
3864  0x386E6000,
3865  0x386E8000,
3866  0x386EA000,
3867  0x386EC000,
3868  0x386EE000,
3869  0x386F0000,
3870  0x386F2000,
3871  0x386F4000,
3872  0x386F6000,
3873  0x386F8000,
3874  0x386FA000,
3875  0x386FC000,
3876  0x386FE000,
3877  0x38700000,
3878  0x38702000,
3879  0x38704000,
3880  0x38706000,
3881  0x38708000,
3882  0x3870A000,
3883  0x3870C000,
3884  0x3870E000,
3885  0x38710000,
3886  0x38712000,
3887  0x38714000,
3888  0x38716000,
3889  0x38718000,
3890  0x3871A000,
3891  0x3871C000,
3892  0x3871E000,
3893  0x38720000,
3894  0x38722000,
3895  0x38724000,
3896  0x38726000,
3897  0x38728000,
3898  0x3872A000,
3899  0x3872C000,
3900  0x3872E000,
3901  0x38730000,
3902  0x38732000,
3903  0x38734000,
3904  0x38736000,
3905  0x38738000,
3906  0x3873A000,
3907  0x3873C000,
3908  0x3873E000,
3909  0x38740000,
3910  0x38742000,
3911  0x38744000,
3912  0x38746000,
3913  0x38748000,
3914  0x3874A000,
3915  0x3874C000,
3916  0x3874E000,
3917  0x38750000,
3918  0x38752000,
3919  0x38754000,
3920  0x38756000,
3921  0x38758000,
3922  0x3875A000,
3923  0x3875C000,
3924  0x3875E000,
3925  0x38760000,
3926  0x38762000,
3927  0x38764000,
3928  0x38766000,
3929  0x38768000,
3930  0x3876A000,
3931  0x3876C000,
3932  0x3876E000,
3933  0x38770000,
3934  0x38772000,
3935  0x38774000,
3936  0x38776000,
3937  0x38778000,
3938  0x3877A000,
3939  0x3877C000,
3940  0x3877E000,
3941  0x38780000,
3942  0x38782000,
3943  0x38784000,
3944  0x38786000,
3945  0x38788000,
3946  0x3878A000,
3947  0x3878C000,
3948  0x3878E000,
3949  0x38790000,
3950  0x38792000,
3951  0x38794000,
3952  0x38796000,
3953  0x38798000,
3954  0x3879A000,
3955  0x3879C000,
3956  0x3879E000,
3957  0x387A0000,
3958  0x387A2000,
3959  0x387A4000,
3960  0x387A6000,
3961  0x387A8000,
3962  0x387AA000,
3963  0x387AC000,
3964  0x387AE000,
3965  0x387B0000,
3966  0x387B2000,
3967  0x387B4000,
3968  0x387B6000,
3969  0x387B8000,
3970  0x387BA000,
3971  0x387BC000,
3972  0x387BE000,
3973  0x387C0000,
3974  0x387C2000,
3975  0x387C4000,
3976  0x387C6000,
3977  0x387C8000,
3978  0x387CA000,
3979  0x387CC000,
3980  0x387CE000,
3981  0x387D0000,
3982  0x387D2000,
3983  0x387D4000,
3984  0x387D6000,
3985  0x387D8000,
3986  0x387DA000,
3987  0x387DC000,
3988  0x387DE000,
3989  0x387E0000,
3990  0x387E2000,
3991  0x387E4000,
3992  0x387E6000,
3993  0x387E8000,
3994  0x387EA000,
3995  0x387EC000,
3996  0x387EE000,
3997  0x387F0000,
3998  0x387F2000,
3999  0x387F4000,
4000  0x387F6000,
4001  0x387F8000,
4002  0x387FA000,
4003  0x387FC000,
4004  0x387FE000};
4005  static const bits<float>::type exponent_table[64] = {
4006  0x00000000,
4007  0x00800000,
4008  0x01000000,
4009  0x01800000,
4010  0x02000000,
4011  0x02800000,
4012  0x03000000,
4013  0x03800000,
4014  0x04000000,
4015  0x04800000,
4016  0x05000000,
4017  0x05800000,
4018  0x06000000,
4019  0x06800000,
4020  0x07000000,
4021  0x07800000,
4022  0x08000000,
4023  0x08800000,
4024  0x09000000,
4025  0x09800000,
4026  0x0A000000,
4027  0x0A800000,
4028  0x0B000000,
4029  0x0B800000,
4030  0x0C000000,
4031  0x0C800000,
4032  0x0D000000,
4033  0x0D800000,
4034  0x0E000000,
4035  0x0E800000,
4036  0x0F000000,
4037  0x47800000,
4038  0x80000000,
4039  0x80800000,
4040  0x81000000,
4041  0x81800000,
4042  0x82000000,
4043  0x82800000,
4044  0x83000000,
4045  0x83800000,
4046  0x84000000,
4047  0x84800000,
4048  0x85000000,
4049  0x85800000,
4050  0x86000000,
4051  0x86800000,
4052  0x87000000,
4053  0x87800000,
4054  0x88000000,
4055  0x88800000,
4056  0x89000000,
4057  0x89800000,
4058  0x8A000000,
4059  0x8A800000,
4060  0x8B000000,
4061  0x8B800000,
4062  0x8C000000,
4063  0x8C800000,
4064  0x8D000000,
4065  0x8D800000,
4066  0x8E000000,
4067  0x8E800000,
4068  0x8F000000,
4069  0xC7800000};
4070  static const unsigned short offset_table[64] = {
4071  0,
4072  1024,
4073  1024,
4074  1024,
4075  1024,
4076  1024,
4077  1024,
4078  1024,
4079  1024,
4080  1024,
4081  1024,
4082  1024,
4083  1024,
4084  1024,
4085  1024,
4086  1024,
4087  1024,
4088  1024,
4089  1024,
4090  1024,
4091  1024,
4092  1024,
4093  1024,
4094  1024,
4095  1024,
4096  1024,
4097  1024,
4098  1024,
4099  1024,
4100  1024,
4101  1024,
4102  1024,
4103  0,
4104  1024,
4105  1024,
4106  1024,
4107  1024,
4108  1024,
4109  1024,
4110  1024,
4111  1024,
4112  1024,
4113  1024,
4114  1024,
4115  1024,
4116  1024,
4117  1024,
4118  1024,
4119  1024,
4120  1024,
4121  1024,
4122  1024,
4123  1024,
4124  1024,
4125  1024,
4126  1024,
4127  1024,
4128  1024,
4129  1024,
4130  1024,
4131  1024,
4132  1024,
4133  1024,
4134  1024};
4135  bits<float>::type fbits = mantissa_table[offset_table[value >> 10] + (value & 0x3FF)] + exponent_table[value >> 10];
4136 #endif
4137  float out;
4138  std::memcpy(&out, &fbits, sizeof(float));
4139  return out;
4140 #endif
4141 }
4142 

◆ half2float_impl() [3/3]

template<typename T >
T half_float::detail::half2float_impl ( unsigned int  value,
,
  ... 
)

Convert half-precision to non-IEEE floating-point.

Template Parameters
Ttype to convert to (builtin integer type)
Parameters
valuehalf-precision value to convert
Returns
floating-point value

Definition at line 4173 of file half.hpp.

4173 {
4174  T out;
4175  unsigned int abs = value & 0x7FFF;
4176  if (abs > 0x7C00)
4177  out = (std::numeric_limits<T>::has_signaling_NaN && !(abs & 0x200)) ? std::numeric_limits<T>::signaling_NaN() : std::numeric_limits<T>::has_quiet_NaN ? std::numeric_limits<T>::quiet_NaN()
4178  : T();
4179  else if (abs == 0x7C00)
4180  out = std::numeric_limits<T>::has_infinity ? std::numeric_limits<T>::infinity() : std::numeric_limits<T>::max();
4181  else if (abs > 0x3FF)
4182  out = ldexp(static_cast<T>((abs & 0x3FF) | 0x400), (abs >> 10) - 25);
4183  else
4184  out = ldexp(static_cast<T>(abs), -24);
4185  return (value & 0x8000) ? -out : out;
4186 }
4187 
Extensions to the C++ standard library.
Definition: half.hpp:5447

◆ half2int()

template<std::float_round_style R, bool E, bool I, typename T >
T half_float::detail::half2int ( unsigned int  value)

Convert half-precision floating-point to integer.

Template Parameters
Rrounding mode to use
Etrue for round to even, false for round away from zero
Itrue to raise INEXACT exception (if inexact), false to never raise it
Ttype to convert to (buitlin integer type with at least 16 bits precision, excluding any implicit sign bits)
Parameters
valuehalf-precision value to convert
Returns
rounded integer value
Exceptions
MU_HALF_FE_INVALIDif value is not representable in type T
MU_HALF_FE_INEXACTif value had to be rounded and I is true

Definition at line 4209 of file half.hpp.

4209 {
4210  unsigned int abs = value & 0x7FFF;
4211  if (abs >= 0x7C00)
4212  {
4213  raise(MU_HALF_FE_INVALID);
4214  return (value & 0x8000) ? std::numeric_limits<T>::min() : std::numeric_limits<T>::max();
4215  }
4216  if (abs < 0x3800)
4217  {
4218  raise(MU_HALF_FE_INEXACT, I);
4219  return (R == std::round_toward_infinity) ? T(~(value >> 15) & (abs != 0)) : (R == std::round_toward_neg_infinity) ? -T(value > 0x8000)
4220  : T();
4221  }
4222  int exp = 25 - (abs >> 10);
4223  unsigned int m = (value & 0x3FF) | 0x400;
4224  int32 i = static_cast<int32>((exp <= 0) ? (m << -exp) : ((m + ((R == std::round_to_nearest) ? ((1 << (exp - 1)) - (~(m >> exp) & E)) : (R == std::round_toward_infinity) ? (((1 << exp) - 1) & ((value >> 15) - 1))
4225  : (R == std::round_toward_neg_infinity) ? (((1 << exp) - 1) & -(value >> 15))
4226  : 0)) >>
4227  exp));
4228  if ((!std::numeric_limits<T>::is_signed && (value & 0x8000)) || (std::numeric_limits<T>::digits < 16 &&
4229  ((value & 0x8000) ? (-i < std::numeric_limits<T>::min()) : (i > std::numeric_limits<T>::max()))))
4230  raise(MU_HALF_FE_INVALID);
4231  else if (I && exp > 0 && (m & ((1 << exp) - 1)))
4232  raise(MU_HALF_FE_INEXACT);
4233  return static_cast<T>((value & 0x8000) ? -i : i);
4234 }
4235 
#define MU_HALF_FE_INEXACT
Definition: half.hpp:45

◆ hyperbolic_args()

std::pair<uint32, uint32> half_float::detail::hyperbolic_args ( unsigned int  abs,
int &  exp,
unsigned int  n = 32 
)
inline

Get exponentials for hyperbolic computation

Parameters
abshalf-precision floating-point value
expvariable to take unbiased exponent of larger result
nnumber of BKM iterations (at most 32)
Returns
exp(abs) and exp(-abs) as Q1.31 with same exponent

Definition at line 4665 of file half.hpp.

4665 {
4666  uint32 mx = detail::multiply64(static_cast<uint32>((abs & 0x3FF) + ((abs > 0x3FF) << 10)) << 21, 0xB8AA3B29), my;
4667  int e = (abs >> 10) + (abs <= 0x3FF);
4668  if (e < 14)
4669  {
4670  exp = 0;
4671  mx >>= 14 - e;
4672  }
4673  else
4674  {
4675  exp = mx >> (45 - e);
4676  mx = (mx << (e - 14)) & 0x7FFFFFFF;
4677  }
4678  mx = exp2(mx, n);
4679  int d = exp << 1, s;
4680  if (mx > 0x80000000)
4681  {
4682  my = divide64(0x80000000, mx, s);
4683  my |= s;
4684  ++d;
4685  }
4686  else
4687  my = mx;
4688  return std::make_pair(mx, (d < 31) ? ((my >> d) | ((my & ((static_cast<uint32>(1) << d) - 1)) != 0)) : 1);
4689 }
4690 

◆ hypot_post()

template<std::float_round_style R>
unsigned int half_float::detail::hypot_post ( uint32  r,
int  exp 
)

Hypotenuse square root and postprocessing.

Template Parameters
Rrounding mode to use
Parameters
rmantissa as Q2.30
expbiased exponent
Returns
square root converted to half-precision
Exceptions
MU_HALF_FE_OVERFLOWon overflows
MU_HALF_FE_UNDERFLOWon underflows
MU_HALF_FE_INEXACTif value had to be rounded

Definition at line 4764 of file half.hpp.

4764 {
4765  int i = r >> 31;
4766  if ((exp += i) > 46)
4767  return overflow<R>();
4768  if (exp < -34)
4769  return underflow<R>();
4770  r = (r >> i) | (r & i);
4771  uint32 m = sqrt<30>(r, exp += 15);
4772  return fixed2half<R, 15, false, false, false>(m, exp - 1, 0, r != 0);
4773 }
4774 

◆ int2half()

template<std::float_round_style R, typename T >
unsigned int half_float::detail::int2half ( value)

Convert integer to half-precision floating-point.

Template Parameters
Rrounding mode to use
Ttype to convert (builtin integer type)
Parameters
valueintegral value to convert
Returns
rounded half-precision value
Exceptions
MU_HALF_FE_OVERFLOWon overflows
MU_HALF_FE_INEXACTif value had to be rounded

Definition at line 1919 of file half.hpp.

1919 {
1920  unsigned int bits = static_cast<unsigned>(value < 0) << 15;
1921  if (!value)
1922  return bits;
1923  if (bits)
1924  value = -value;
1925  if (value > 0xFFFF)
1926  return overflow<R>(bits);
1927  unsigned int m = static_cast<unsigned int>(value), exp = 24;
1928  for (; m < 0x400; m <<= 1, --exp)
1929  ;
1930  for (; m > 0x7FF; m >>= 1, ++exp)
1931  ;
1932  bits |= (exp << 10) + m;
1933  return (exp > 24) ? rounded<R, false>(bits, (value >> (exp - 25)) & 1, (((1 << (exp - 25)) - 1) & value) != 0) : bits;
1934 }
1935 

◆ integral()

template<std::float_round_style R, bool E, bool I>
unsigned int half_float::detail::integral ( unsigned int  value)

Round half-precision number to nearest integer value.

Template Parameters
Rrounding mode to use
Etrue for round to even, false for round away from zero
Itrue to raise INEXACT exception (if inexact), false to never raise it
Parameters
valuehalf-precision value to round
Returns
half-precision bits for nearest integral value
Exceptions
MU_HALF_FE_INVALIDfor signaling NaN
MU_HALF_FE_INEXACTif value had to be rounded and I is true

Definition at line 957 of file half.hpp.

957 {
958  unsigned int abs = value & 0x7FFF;
959  if (abs < 0x3C00)
960  {
961  raise(MU_HALF_FE_INEXACT, I);
962  return ((R == std::round_to_nearest) ? (0x3C00 & -static_cast<unsigned>(abs >= (0x3800 + E))) : (R == std::round_toward_infinity) ? (0x3C00 & -(~(value >> 15) & (abs != 0)))
963  : (R == std::round_toward_neg_infinity) ? (0x3C00 & -static_cast<unsigned>(value > 0x8000))
964  : 0) |
965  (value & 0x8000);
966  }
967  if (abs >= 0x6400)
968  return (abs > 0x7C00) ? signal(value) : value;
969  unsigned int exp = 25 - (abs >> 10), mask = (1 << exp) - 1;
970  raise(MU_HALF_FE_INEXACT, I && (value & mask));
971  return (((R == std::round_to_nearest) ? ((1 << (exp - 1)) - (~(value >> exp) & E)) : (R == std::round_toward_infinity) ? (mask & ((value >> 15) - 1))
972  : (R == std::round_toward_neg_infinity) ? (mask & -(value >> 15))
973  : 0) +
974  value) &
975  ~mask;
976 }
977 
HALF_CONSTEXPR_NOERR unsigned int signal(unsigned int x, unsigned int y, unsigned int z)
Definition: half.hpp:824

◆ invalid()

HALF_CONSTEXPR_NOERR unsigned int half_float::detail::invalid ( )
inline

Raise domain error and return NaN. return quiet NaN

Exceptions
MU_HALF_FE_INVALID

Definition at line 850 of file half.hpp.

850 {
851 #if HALF_ERRHANDLING
852  raise(MU_HALF_FE_INVALID);
853 #endif
854  return 0x7FFF;
855 }
856 

◆ log2()

uint32 half_float::detail::log2 ( uint32  m,
unsigned int  n = 32 
)
inline

Fixed point binary logarithm. This uses the BKM algorithm in L-mode.

Parameters
mmantissa in [1,2) as Q1.30
nnumber of iterations (at most 32)
Returns
log2(m) as Q0.31

Definition at line 4458 of file half.hpp.

4458 {
4459  static const uint32 logs[] = {
4460  0x80000000,
4461  0x4AE00D1D,
4462  0x2934F098,
4463  0x15C01A3A,
4464  0x0B31FB7D,
4465  0x05AEB4DD,
4466  0x02DCF2D1,
4467  0x016FE50B,
4468  0x00B84E23,
4469  0x005C3E10,
4470  0x002E24CA,
4471  0x001713D6,
4472  0x000B8A47,
4473  0x0005C53B,
4474  0x0002E2A3,
4475  0x00017153,
4476  0x0000B8AA,
4477  0x00005C55,
4478  0x00002E2B,
4479  0x00001715,
4480  0x00000B8B,
4481  0x000005C5,
4482  0x000002E3,
4483  0x00000171,
4484  0x000000B9,
4485  0x0000005C,
4486  0x0000002E,
4487  0x00000017,
4488  0x0000000C,
4489  0x00000006,
4490  0x00000003,
4491  0x00000001};
4492  if (m == 0x40000000)
4493  return 0;
4494  uint32 mx = 0x40000000, my = 0;
4495  for (unsigned int i = 1; i < n; ++i)
4496  {
4497  uint32 mz = mx + (mx >> i);
4498  if (mz <= m)
4499  {
4500  mx = mz;
4501  my += logs[i];
4502  }
4503  }
4504  return my;
4505 }
4506 

◆ log2_post()

template<std::float_round_style R, uint32 L>
unsigned int half_float::detail::log2_post ( uint32  m,
int  ilog,
int  exp,
unsigned int  sign = 0 
)

Postprocessing for binary logarithm.

Template Parameters
Rrounding mode to use
Llogarithm for base transformation as Q1.31
Parameters
mfractional part of logarithm as Q0.31
ilogsigned integer part of logarithm
expbiased exponent of result
signsign bit of result
Returns
value base-transformed and converted to half-precision
Exceptions
MU_HALF_FE_OVERFLOWon overflows
MU_HALF_FE_UNDERFLOWon underflows
MU_HALF_FE_INEXACTif no other exception occurred

Definition at line 4737 of file half.hpp.

4737 {
4738  uint32 msign = sign_mask(ilog);
4739  m = (((static_cast<uint32>(ilog) << 27) + (m >> 4)) ^ msign) - msign;
4740  if (!m)
4741  return 0;
4742  for (; m < 0x80000000; m <<= 1, --exp)
4743  ;
4744  int i = m >= L, s;
4745  exp += i;
4746  m >>= 1 + i;
4747  sign ^= msign & 0x8000;
4748  if (exp < -11)
4749  return underflow<R>(sign);
4750  m = divide64(m, L, s);
4751  return fixed2half<R, 30, false, false, true>(m, exp, sign, 1);
4752 }
4753 

◆ mod()

template<bool Q, bool R>
unsigned int half_float::detail::mod ( unsigned int  x,
unsigned int  y,
int *  quo = NULL 
)

Half precision positive modulus.

Template Parameters
Qtrue to compute full quotient, false else
Rtrue to compute signed remainder, false for positive remainder
Parameters
xfirst operand as positive finite half-precision value
ysecond operand as positive finite half-precision value
quoadress to store quotient at, nullptr if Q false
Returns
modulus of x / y

Definition at line 4303 of file half.hpp.

4303 {
4304  unsigned int q = 0;
4305  if (x > y)
4306  {
4307  int absx = x, absy = y, expx = 0, expy = 0;
4308  for (; absx < 0x400; absx <<= 1, --expx)
4309  ;
4310  for (; absy < 0x400; absy <<= 1, --expy)
4311  ;
4312  expx += absx >> 10;
4313  expy += absy >> 10;
4314  int mx = (absx & 0x3FF) | 0x400, my = (absy & 0x3FF) | 0x400;
4315  for (int d = expx - expy; d; --d)
4316  {
4317  if (!Q && mx == my)
4318  return 0;
4319  if (mx >= my)
4320  {
4321  mx -= my;
4322  q += Q;
4323  }
4324  mx <<= 1;
4325  q <<= static_cast<int>(Q);
4326  }
4327  if (!Q && mx == my)
4328  return 0;
4329  if (mx >= my)
4330  {
4331  mx -= my;
4332  ++q;
4333  }
4334  if (Q)
4335  {
4336  q &= (1 << (std::numeric_limits<int>::digits - 1)) - 1;
4337  if (!mx)
4338  return *quo = q, 0;
4339  }
4340  for (; mx < 0x400; mx <<= 1, --expy)
4341  ;
4342  x = (expy > 0) ? ((expy << 10) | (mx & 0x3FF)) : (mx >> (1 - expy));
4343  }
4344  if (R)
4345  {
4346  unsigned int a, b;
4347  if (y < 0x800)
4348  {
4349  a = (x < 0x400) ? (x << 1) : (x + 0x400);
4350  b = y;
4351  }
4352  else
4353  {
4354  a = x;
4355  b = y - 0x400;
4356  }
4357  if (a > b || (a == b && (q & 1)))
4358  {
4359  int exp = (y >> 10) + (y <= 0x3FF), d = exp - (x >> 10) - (x <= 0x3FF);
4360  int m = (((y & 0x3FF) | ((y > 0x3FF) << 10)) << 1) - (((x & 0x3FF) | ((x > 0x3FF) << 10)) << (1 - d));
4361  for (; m < 0x800 && exp > 1; m <<= 1, --exp)
4362  ;
4363  x = 0x8000 + ((exp - 1) << 10) + (m >> 1);
4364  q += Q;
4365  }
4366  }
4367  if (Q)
4368  *quo = q;
4369  return x;
4370 }
4371 

◆ mulhi()

template<std::float_round_style R>
uint32 half_float::detail::mulhi ( uint32  x,
uint32  y 
)

upper part of 64-bit multiplication.

Template Parameters
Rrounding mode to use
Parameters
xfirst factor
ysecond factor
Returns
upper 32 bit of x * y

Definition at line 4247 of file half.hpp.

4247 {
4248  uint32 xy = (x >> 16) * (y & 0xFFFF), yx = (x & 0xFFFF) * (y >> 16), c = (xy & 0xFFFF) + (yx & 0xFFFF) + (((x & 0xFFFF) * (y & 0xFFFF)) >> 16);
4249  return (x >> 16) * (y >> 16) + (xy >> 16) + (yx >> 16) + (c >> 16) +
4250  ((R == std::round_to_nearest) ? ((c >> 15) & 1) : (R == std::round_toward_infinity) ? ((c & 0xFFFF) != 0)
4251  : 0);
4252 }
4253 

◆ multiply64()

uint32 half_float::detail::multiply64 ( uint32  x,
uint32  y 
)
inline

64-bit multiplication.

Parameters
xfirst factor
ysecond factor
Returns
upper 32 bit of x * y rounded to nearest

Definition at line 4259 of file half.hpp.

4259 {
4260 #if HALF_ENABLE_CPP11_LONG_LONG
4261  return static_cast<uint32>((static_cast<unsigned long long>(x) * static_cast<unsigned long long>(y) + 0x80000000) >> 32);
4262 #else
4263  return mulhi<std::round_to_nearest>(x, y);
4264 #endif
4265 }
4266 

◆ overflow()

template<std::float_round_style R>
HALF_CONSTEXPR_NOERR unsigned int half_float::detail::overflow ( unsigned int  sign = 0)

Half-precision overflow.

Template Parameters
Rrounding mode to use
Parameters
signhalf-precision value with sign bit only
Returns
rounded overflowing half-precision value
Exceptions
MU_HALF_FE_OVERFLOW

Definition at line 892 of file half.hpp.

892 {
893 #if HALF_ERRHANDLING
894  raise(MU_HALF_FE_OVERFLOW);
895 #endif
896  return (R == std::round_toward_infinity) ? (sign + 0x7C00 - (sign >> 15)) : (R == std::round_toward_neg_infinity) ? (sign + 0x7BFF + (sign >> 15))
897  : (R == std::round_toward_zero) ? (sign | 0x7BFF)
898  : (sign | 0x7C00);
899 }
900 
#define MU_HALF_FE_OVERFLOW
Definition: half.hpp:43

◆ pole()

HALF_CONSTEXPR_NOERR unsigned int half_float::detail::pole ( unsigned int  sign = 0)
inline

Raise pole error and return infinity.

Parameters
signhalf-precision value with sign bit only
Returns
half-precision infinity with sign of sign
Exceptions
MU_HALF_FE_DIVBYZERO

Definition at line 862 of file half.hpp.

862 {
863 #if HALF_ERRHANDLING
864  raise(MU_HALF_FE_DIVBYZERO);
865 #endif
866  return sign | 0x7C00;
867 }
868 
#define MU_HALF_FE_DIVBYZERO
Definition: half.hpp:42

◆ raise()

void half_float::detail::raise ( int   HALF_UNUSED_NOERRflags,
bool   HALF_UNUSED_NOERRcond = true 
)
inline

Raise floating-point exception.

Parameters
flagsexceptions to raise
condcondition to raise exceptions for

Definition at line 731 of file half.hpp.

731 {
732 #if HALF_ERRHANDLING
733  if (!cond)
734  return;
735 #if HALF_ERRHANDLING_FLAGS
736  errflags() |= flags;
737 #endif
738 #if HALF_ERRHANDLING_ERRNO
739  if (flags & MU_HALF_FE_INVALID)
740  errno = EDOM;
742  errno = ERANGE;
743 #endif
744 #if HALF_ERRHANDLING_FENV && HALF_ENABLE_CPP11_CFENV
745  std::feraiseexcept(flags);
746 #endif
747 #ifdef HALF_ERRHANDLING_THROW_INVALID
748  if (flags & MU_HALF_FE_INVALID)
749  throw std::domain_error(HALF_ERRHANDLING_THROW_INVALID);
750 #endif
751 #ifdef HALF_ERRHANDLING_THROW_DIVBYZERO
752  if (flags & MU_HALF_FE_DIVBYZERO)
753  throw std::domain_error(HALF_ERRHANDLING_THROW_DIVBYZERO);
754 #endif
755 #ifdef HALF_ERRHANDLING_THROW_OVERFLOW
756  if (flags & MU_HALF_FE_OVERFLOW)
757  throw std::overflow_error(HALF_ERRHANDLING_THROW_OVERFLOW);
758 #endif
759 #ifdef HALF_ERRHANDLING_THROW_UNDERFLOW
760  if (flags & MU_HALF_FE_UNDERFLOW)
761  throw std::underflow_error(HALF_ERRHANDLING_THROW_UNDERFLOW);
762 #endif
763 #ifdef HALF_ERRHANDLING_THROW_INEXACT
764  if (flags & MU_HALF_FE_INEXACT)
765  throw std::range_error(HALF_ERRHANDLING_THROW_INEXACT);
766 #endif
767 #if HALF_ERRHANDLING_UNDERFLOW_TO_INEXACT
768  if ((flags & MU_HALF_FE_UNDERFLOW) && !(flags & MU_HALF_FE_INEXACT))
769  raise(MU_HALF_FE_INEXACT);
770 #endif
771 #if HALF_ERRHANDLING_OVERFLOW_TO_INEXACT
772  if ((flags & MU_HALF_FE_OVERFLOW) && !(flags & MU_HALF_FE_INEXACT))
773  raise(MU_HALF_FE_INEXACT);
774 #endif
775 #endif
776 }
777 
int & errflags()
Definition: half.hpp:722
int feraiseexcept(int excepts)
Definition: half.hpp:7834

◆ rounded()

template<std::float_round_style R, bool I>
HALF_CONSTEXPR_NOERR unsigned int half_float::detail::rounded ( unsigned int  value,
int  g,
int  s 
)

Round half-precision number.

Template Parameters
Rrounding mode to use
Itrue to always raise INEXACT exception, false to raise only for rounded results
Parameters
valuefinite half-precision number to round
gguard bit (most significant discarded bit)
ssticky bit (or of all but the most significant discarded bits)
Returns
rounded half-precision value
Exceptions
MU_HALF_FE_OVERFLOWon overflows
MU_HALF_FE_UNDERFLOWon underflows
MU_HALF_FE_INEXACTif value had to be rounded or I is true

Definition at line 928 of file half.hpp.

928 {
929 #if HALF_ERRHANDLING
930  value += (R == std::round_to_nearest) ? (g & (s | value)) : (R == std::round_toward_infinity) ? (~(value >> 15) & (g | s))
931  : (R == std::round_toward_neg_infinity) ? ((value >> 15) & (g | s))
932  : 0;
933  if ((value & 0x7C00) == 0x7C00)
934  raise(MU_HALF_FE_OVERFLOW);
935  else if (value & 0x7C00)
936  raise(MU_HALF_FE_INEXACT, I || (g | s) != 0);
937  else
938  raise(MU_HALF_FE_UNDERFLOW, !(HALF_ERRHANDLING_UNDERFLOW_TO_INEXACT) || I || (g | s) != 0);
939  return value;
940 #else
941  return (R == std::round_to_nearest) ? (value + (g & (s | value))) : (R == std::round_toward_infinity) ? (value + (~(value >> 15) & (g | s)))
942  : (R == std::round_toward_neg_infinity) ? (value + ((value >> 15) & (g | s)))
943  : value;
944 #endif
945 }
946 
#define HALF_ERRHANDLING_UNDERFLOW_TO_INEXACT
Definition: half.hpp:377

◆ select()

HALF_CONSTEXPR_NOERR unsigned int half_float::detail::select ( unsigned int  x,
unsigned int   HALF_UNUSED_NOERR
)
inline

Select value or signaling NaN.

Parameters
xpreferred half-precision value
yignored half-precision value except for signaling NaN
Returns
y if signaling NaN, x otherwise
Exceptions
MU_HALF_FE_INVALIDif y is signaling NaN

Definition at line 838 of file half.hpp.

838 {
839 #if HALF_ERRHANDLING
840  return (((y & 0x7FFF) > 0x7C00) && !(y & 0x200)) ? signal(y) : x;
841 #else
842  return x;
843 #endif
844 }
845 

◆ sign_mask()

uint32 half_float::detail::sign_mask ( uint32  arg)
inline

Platform-independent sign mask.

Parameters
arginteger value in two's complement
Return values
-1if arg negative
0if arg positive

Definition at line 693 of file half.hpp.

693 {
694  static const int N = std::numeric_limits<uint32>::digits - 1;
695 #if HALF_TWOS_COMPLEMENT_INT
696  return static_cast<int32>(arg) >> N;
697 #else
698  return -((arg >> N) & 1);
699 #endif
700 }
701 

◆ signal() [1/3]

HALF_CONSTEXPR_NOERR unsigned int half_float::detail::signal ( unsigned int  nan)
inline

Signal and silence signaling NaN.

Parameters
nanhalf-precision NaN value
Returns
quiet NaN
Exceptions
MU_HALF_FE_INVALIDif nan is signaling NaN

Definition at line 797 of file half.hpp.

797 {
798 #if HALF_ERRHANDLING
799  raise(MU_HALF_FE_INVALID, !(nan & 0x200));
800 #endif
801  return nan | 0x200;
802 }
803 

◆ signal() [2/3]

HALF_CONSTEXPR_NOERR unsigned int half_float::detail::signal ( unsigned int  x,
unsigned int  y 
)
inline

Signal and silence signaling NaNs.

Parameters
xfirst half-precision value to check
ysecond half-precision value to check
Returns
quiet NaN
Exceptions
MU_HALF_FE_INVALIDif x or y is signaling NaN

Definition at line 810 of file half.hpp.

810 {
811 #if HALF_ERRHANDLING
812  raise(MU_HALF_FE_INVALID, ((x & 0x7FFF) > 0x7C00 && !(x & 0x200)) || ((y & 0x7FFF) > 0x7C00 && !(y & 0x200)));
813 #endif
814  return ((x & 0x7FFF) > 0x7C00) ? (x | 0x200) : (y | 0x200);
815 }
816 

◆ signal() [3/3]

HALF_CONSTEXPR_NOERR unsigned int half_float::detail::signal ( unsigned int  x,
unsigned int  y,
unsigned int  z 
)
inline

Signal and silence signaling NaNs.

Parameters
xfirst half-precision value to check
ysecond half-precision value to check
zthird half-precision value to check
Returns
quiet NaN
Exceptions
MU_HALF_FE_INVALIDif x, y or z is signaling NaN

Definition at line 824 of file half.hpp.

824 {
825 #if HALF_ERRHANDLING
826  raise(MU_HALF_FE_INVALID, ((x & 0x7FFF) > 0x7C00 && !(x & 0x200)) || ((y & 0x7FFF) > 0x7C00 && !(y & 0x200)) || ((z & 0x7FFF) > 0x7C00 && !(z & 0x200)));
827 #endif
828  return ((x & 0x7FFF) > 0x7C00) ? (x | 0x200) : ((y & 0x7FFF) > 0x7C00) ? (y | 0x200)
829  : (z | 0x200);
830 }
831 

◆ sincos()

std::pair<uint32, uint32> half_float::detail::sincos ( uint32  mz,
unsigned int  n = 31 
)
inline

Fixed point sine and cosine. This uses the CORDIC algorithm in rotation mode.

Parameters
mzangle in [-pi/2,pi/2] as Q1.30
nnumber of iterations (at most 31)
Returns
sine and cosine of mz as Q1.30

Definition at line 4513 of file half.hpp.

4513 {
4514  static const uint32 angles[] = {
4515  0x3243F6A9,
4516  0x1DAC6705,
4517  0x0FADBAFD,
4518  0x07F56EA7,
4519  0x03FEAB77,
4520  0x01FFD55C,
4521  0x00FFFAAB,
4522  0x007FFF55,
4523  0x003FFFEB,
4524  0x001FFFFD,
4525  0x00100000,
4526  0x00080000,
4527  0x00040000,
4528  0x00020000,
4529  0x00010000,
4530  0x00008000,
4531  0x00004000,
4532  0x00002000,
4533  0x00001000,
4534  0x00000800,
4535  0x00000400,
4536  0x00000200,
4537  0x00000100,
4538  0x00000080,
4539  0x00000040,
4540  0x00000020,
4541  0x00000010,
4542  0x00000008,
4543  0x00000004,
4544  0x00000002,
4545  0x00000001};
4546  uint32 mx = 0x26DD3B6A, my = 0;
4547  for (unsigned int i = 0; i < n; ++i)
4548  {
4549  uint32 sign = sign_mask(mz);
4550  uint32 tx = mx - (arithmetic_shift(my, i) ^ sign) + sign;
4551  uint32 ty = my + (arithmetic_shift(mx, i) ^ sign) - sign;
4552  mx = tx;
4553  my = ty;
4554  mz -= (angles[i] ^ sign) - sign;
4555  }
4556  return std::make_pair(my, mx);
4557 }
4558 

◆ sqrt()

template<unsigned int F>
uint32 half_float::detail::sqrt ( uint32 r,
int &  exp 
)

Fixed point square root.

Template Parameters
Fnumber of fractional bits
Parameters
rradicand in Q1.F fixed point format
expexponent
Returns
square root as Q1.F/2

Definition at line 4379 of file half.hpp.

4379 {
4380  int i = exp & 1;
4381  r <<= i;
4382  exp = (exp - i) / 2;
4383  uint32 m = 0;
4384  for (uint32 bit = static_cast<uint32>(1) << F; bit; bit >>= 2)
4385  {
4386  if (r < m + bit)
4387  m >>= 1;
4388  else
4389  {
4390  r -= m + bit;
4391  m = (m >> 1) + bit;
4392  }
4393  }
4394  return m;
4395 }
4396 

◆ tangent_post()

template<std::float_round_style R>
unsigned int half_float::detail::tangent_post ( uint32  my,
uint32  mx,
int  exp,
unsigned int  sign = 0 
)

Division and postprocessing for tangents.

Template Parameters
Rrounding mode to use
Parameters
mydividend as Q1.31
mxdivisor as Q1.31
expbiased exponent of result
signsign bit of result
Returns
quotient converted to half-precision
Exceptions
MU_HALF_FE_OVERFLOWon overflows
MU_HALF_FE_UNDERFLOWon underflows
MU_HALF_FE_INEXACTif no other exception occurred

Definition at line 4787 of file half.hpp.

4787 {
4788  int i = my >= mx, s;
4789  exp += i;
4790  if (exp > 29)
4791  return overflow<R>(sign);
4792  if (exp < -11)
4793  return underflow<R>(sign);
4794  uint32 m = divide64(my >> (i + 1), mx, s);
4795  return fixed2half<R, 30, false, false, true>(m, exp, sign, s);
4796 }
4797 

◆ underflow()

template<std::float_round_style R>
HALF_CONSTEXPR_NOERR unsigned int half_float::detail::underflow ( unsigned int  sign = 0)

Half-precision underflow.

Template Parameters
Rrounding mode to use
Parameters
signhalf-precision value with sign bit only
Returns
rounded underflowing half-precision value
Exceptions
MU_HALF_FE_UNDERFLOW

Definition at line 908 of file half.hpp.

908 {
909 #if HALF_ERRHANDLING
910  raise(MU_HALF_FE_UNDERFLOW);
911 #endif
912  return (R == std::round_toward_infinity) ? (sign + 1 - (sign >> 15)) : (R == std::round_toward_neg_infinity) ? (sign + (sign >> 15))
913  : sign;
914 }
915 

Variable Documentation

◆ binary

HALF_CONSTEXPR_CONST binary_t half_float::detail::binary = binary_t()

Tag for binary construction.

Definition at line 635 of file half.hpp.