PPL  1.2
Parma_Polyhedra_Library::float_ieee754_half Struct Reference

#include <Float_defs.hh>

Public Member Functions

int inf_sign () const
 
bool is_nan () const
 
int zero_sign () const
 
bool sign_bit () const
 
void negate ()
 
void dec ()
 
void inc ()
 
void set_max (bool negative)
 
void build (bool negative, mpz_t mantissa, int exponent)
 

Public Attributes

uint16_t word
 

Static Public Attributes

static const uint16_t SGN_MASK = 0x8000U
 
static const uint16_t EXP_MASK = 0xfc00U
 
static const uint16_t WRD_MAX = 0x7bffU
 
static const uint16_t POS_INF = 0x7c00U
 
static const uint16_t NEG_INF = 0xfc00U
 
static const uint16_t POS_ZERO = 0x0000U
 
static const uint16_t NEG_ZERO = 0x8000U
 
static const unsigned int BASE = 2
 
static const unsigned int EXPONENT_BITS = 5
 
static const unsigned int MANTISSA_BITS = 10
 
static const int EXPONENT_MAX = (1 << (EXPONENT_BITS - 1)) - 1
 
static const int EXPONENT_BIAS = EXPONENT_MAX
 
static const int EXPONENT_MIN = -EXPONENT_MAX + 1
 
static const int EXPONENT_MIN_DENORM
 
static const Floating_Point_Format floating_point_format = IEEE754_HALF
 

Detailed Description

Definition at line 49 of file Float_defs.hh.

Member Function Documentation

void Parma_Polyhedra_Library::float_ieee754_half::build ( bool  negative,
mpz_t  mantissa,
int  exponent 
)
inline

Definition at line 90 of file Float_inlines.hh.

References EXPONENT_BIAS, EXPONENT_BITS, MANTISSA_BITS, SGN_MASK, and word.

90  {
91  word = static_cast<uint16_t>(mpz_get_ui(mantissa)
92  & ((1UL << MANTISSA_BITS) - 1));
93  if (negative) {
94  word |= SGN_MASK;
95  }
96  const int exponent_repr = exponent + EXPONENT_BIAS;
97  PPL_ASSERT(exponent_repr >= 0 && exponent_repr < (1 << EXPONENT_BITS));
98  word |= static_cast<uint16_t>(exponent_repr) << MANTISSA_BITS;
99 }
static const unsigned int EXPONENT_BITS
Definition: Float_defs.hh:59
static const unsigned int MANTISSA_BITS
Definition: Float_defs.hh:60
void Parma_Polyhedra_Library::float_ieee754_half::dec ( )
inline

Definition at line 72 of file Float_inlines.hh.

References word.

72  {
73  --word;
74 }
void Parma_Polyhedra_Library::float_ieee754_half::inc ( )
inline

Definition at line 77 of file Float_inlines.hh.

References word.

77  {
78  ++word;
79 }
int Parma_Polyhedra_Library::float_ieee754_half::inf_sign ( ) const
inline

Definition at line 35 of file Float_inlines.hh.

References NEG_INF, POS_INF, and word.

35  {
36  if (word == NEG_INF) {
37  return -1;
38  }
39  if (word == POS_INF) {
40  return 1;
41  }
42  return 0;
43 }
bool Parma_Polyhedra_Library::float_ieee754_half::is_nan ( ) const
inline

Definition at line 46 of file Float_inlines.hh.

References POS_INF, SGN_MASK, and word.

46  {
47  return (word & ~SGN_MASK) > POS_INF;
48 }
void Parma_Polyhedra_Library::float_ieee754_half::negate ( )
inline

Definition at line 62 of file Float_inlines.hh.

References SGN_MASK, and word.

void Parma_Polyhedra_Library::float_ieee754_half::set_max ( bool  negative)
inline

Definition at line 82 of file Float_inlines.hh.

References SGN_MASK, word, and WRD_MAX.

82  {
83  word = WRD_MAX;
84  if (negative) {
85  word |= SGN_MASK;
86  }
87 }
bool Parma_Polyhedra_Library::float_ieee754_half::sign_bit ( ) const
inline

Definition at line 67 of file Float_inlines.hh.

References SGN_MASK, and word.

67  {
68  return (word & SGN_MASK) != 0;
69 }
int Parma_Polyhedra_Library::float_ieee754_half::zero_sign ( ) const
inline

Definition at line 51 of file Float_inlines.hh.

References NEG_ZERO, POS_ZERO, and word.

51  {
52  if (word == NEG_ZERO) {
53  return -1;
54  }
55  if (word == POS_ZERO) {
56  return 1;
57  }
58  return 0;
59 }

Member Data Documentation

const unsigned int Parma_Polyhedra_Library::float_ieee754_half::BASE = 2
static
const uint16_t Parma_Polyhedra_Library::float_ieee754_half::EXP_MASK = 0xfc00U
static

Definition at line 52 of file Float_defs.hh.

const int Parma_Polyhedra_Library::float_ieee754_half::EXPONENT_BIAS = EXPONENT_MAX
static

Definition at line 62 of file Float_defs.hh.

Referenced by build(), and Parma_Polyhedra_Library::compute_absolute_error().

const unsigned int Parma_Polyhedra_Library::float_ieee754_half::EXPONENT_BITS = 5
static

Definition at line 59 of file Float_defs.hh.

Referenced by build().

const int Parma_Polyhedra_Library::float_ieee754_half::EXPONENT_MAX = (1 << (EXPONENT_BITS - 1)) - 1
static

Definition at line 61 of file Float_defs.hh.

const int Parma_Polyhedra_Library::float_ieee754_half::EXPONENT_MIN = -EXPONENT_MAX + 1
static

Definition at line 63 of file Float_defs.hh.

const int Parma_Polyhedra_Library::float_ieee754_half::EXPONENT_MIN_DENORM
static
Initial value:
- static_cast<int>(MANTISSA_BITS)

Definition at line 64 of file Float_defs.hh.

const Floating_Point_Format Parma_Polyhedra_Library::float_ieee754_half::floating_point_format = IEEE754_HALF
static

Definition at line 66 of file Float_defs.hh.

const unsigned int Parma_Polyhedra_Library::float_ieee754_half::MANTISSA_BITS = 10
static
const uint16_t Parma_Polyhedra_Library::float_ieee754_half::NEG_INF = 0xfc00U
static

Definition at line 55 of file Float_defs.hh.

Referenced by inf_sign().

const uint16_t Parma_Polyhedra_Library::float_ieee754_half::NEG_ZERO = 0x8000U
static

Definition at line 57 of file Float_defs.hh.

Referenced by zero_sign().

const uint16_t Parma_Polyhedra_Library::float_ieee754_half::POS_INF = 0x7c00U
static

Definition at line 54 of file Float_defs.hh.

Referenced by inf_sign(), and is_nan().

const uint16_t Parma_Polyhedra_Library::float_ieee754_half::POS_ZERO = 0x0000U
static

Definition at line 56 of file Float_defs.hh.

Referenced by zero_sign().

const uint16_t Parma_Polyhedra_Library::float_ieee754_half::SGN_MASK = 0x8000U
static

Definition at line 51 of file Float_defs.hh.

Referenced by build(), is_nan(), negate(), set_max(), and sign_bit().

uint16_t Parma_Polyhedra_Library::float_ieee754_half::word

Definition at line 50 of file Float_defs.hh.

Referenced by build(), dec(), inc(), inf_sign(), is_nan(), negate(), set_max(), sign_bit(), and zero_sign().

const uint16_t Parma_Polyhedra_Library::float_ieee754_half::WRD_MAX = 0x7bffU
static

Definition at line 53 of file Float_defs.hh.

Referenced by set_max().


The documentation for this struct was generated from the following files: