66 class scfx_ieee_double;
68 class scfx_ieee_float;
70 #define SCFX_MASK_(Size) \ 86 #if defined( SC_BIG_ENDIAN ) 89 unsigned mantissa0:20;
90 unsigned mantissa1:32;
91 #elif defined( SC_LITTLE_ENDIAN ) 92 unsigned mantissa1:32;
93 unsigned mantissa0:20;
134 operator double()
const;
136 unsigned int negative()
const;
137 void negative(
unsigned int );
138 int exponent()
const;
139 void exponent(
int );
140 unsigned int mantissa0()
const;
141 void mantissa0(
unsigned int );
142 unsigned int mantissa1()
const;
143 void mantissa1(
unsigned int );
145 bool is_zero()
const;
146 bool is_subnormal()
const;
147 bool is_normal()
const;
202 scfx_ieee_double::operator double()
const 212 return m_id.
s.negative;
233 m_id.
s.exponent = (SCFX_IEEE_DOUBLE_BIAS + a)
241 return m_id.
s.mantissa0;
248 m_id.
s.mantissa0 = a &
SCFX_MASK_(SCFX_IEEE_DOUBLE_M0_SIZE);
255 return m_id.
s.mantissa1;
262 m_id.
s.mantissa1 = a;
270 return (
exponent() == SCFX_IEEE_DOUBLE_E_MIN - 1 &&
278 return (
exponent() == SCFX_IEEE_DOUBLE_E_MIN - 1 &&
286 return (
exponent() >= SCFX_IEEE_DOUBLE_E_MIN &&
287 exponent() <= SCFX_IEEE_DOUBLE_E_MAX );
294 return (
exponent() == SCFX_IEEE_DOUBLE_E_MAX + 1 &&
302 return (
exponent() == SCFX_IEEE_DOUBLE_E_MAX + 1 &&
311 exponent( SCFX_IEEE_DOUBLE_E_MAX + 1 );
320 exponent( SCFX_IEEE_DOUBLE_E_MAX + 1 );
326 #define MSB_STATEMENT(x,n) if( x >> n ) { x >>= n; i += n; } 362 #define LSB_STATEMENT(x,n) if( x << n ) { x <<= n; i -= n; } 431 #if defined( SC_BIG_ENDIAN ) 434 unsigned mantissa:23;
435 #elif defined( SC_LITTLE_ENDIAN ) 436 unsigned mantissa:23;
474 operator float()
const;
480 unsigned int mantissa()
const;
481 void mantissa(
unsigned int );
534 scfx_ieee_float::operator float()
const 544 return m_if.
s.negative;
565 m_if.
s.exponent = (SCFX_IEEE_FLOAT_BIAS + a)
573 return m_if.
s.mantissa;
580 m_if.
s.mantissa = a &
SCFX_MASK_(SCFX_IEEE_FLOAT_M_SIZE);
602 return (
exponent() >= SCFX_IEEE_FLOAT_E_MIN &&
603 exponent() <= SCFX_IEEE_FLOAT_E_MAX );
625 exponent( SCFX_IEEE_FLOAT_E_MAX + 1 );
633 exponent( SCFX_IEEE_FLOAT_E_MAX + 1 );
649 if( exp < SCFX_IEEE_DOUBLE_E_MIN )
654 if( ( exp += 20 ) >= 0 )
658 else if( ( exp += 32 ) >= 0 )
663 else if( exp > SCFX_IEEE_DOUBLE_E_MAX )
687 #if defined( _MSC_VER ) || defined( __clang__ ) 689 double tmp =
static_cast<double>(
static_cast<int64>( a ) );
692 return static_cast<double>( a );
scfx_ieee_float & operator=(float)
Convenient wrapper to union ieee_float.
const unsigned int SCFX_IEEE_DOUBLE_BIAS
unsigned int negative() const
unsigned int mantissa1() const
Convenient interface to union ieee_double.
const int SCFX_IEEE_FLOAT_E_MIN
const unsigned int SCFX_IEEE_DOUBLE_M1_SIZE
static const scfx_ieee_double nan()
double scfx_pow2(int exp)
Computes 2.
const unsigned int SCFX_IEEE_DOUBLE_E_SIZE
unsigned int mantissa() const
const unsigned int SCFX_IEEE_DOUBLE_M_SIZE
struct sc_dt::ieee_float::@2 s
const unsigned int SCFX_IEEE_DOUBLE_M0_SIZE
double uint64_to_double(uint64 a)
Platform independent conversion from double uint64 to double.
IEEE 754 double-precision format.
const unsigned int SCFX_IEEE_FLOAT_E_SIZE
bool is_subnormal() const
const unsigned int SCFX_IEEE_FLOAT_BIAS
scfx_ieee_double & operator=(double)
const int SCFX_IEEE_DOUBLE_E_MAX
static const scfx_ieee_double inf(int)
struct sc_dt::ieee_double::@1 s
const int SCFX_IEEE_DOUBLE_E_MIN
IEEE 754 single-precision format.
bool is_subnormal() const
#define MSB_STATEMENT(x, n)
const unsigned int SCFX_IEEE_FLOAT_M_SIZE
#define LSB_STATEMENT(x, n)
const int SCFX_IEEE_FLOAT_E_MAX
unsigned int negative() const
unsigned int mantissa0() const