Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes | List of all members
internal::Double Class Reference

#include <ieee754.h>

Public Member Functions

 Double ()
 
 Double (double d)
 
 Double (uint64_t u)
 
double Value () const
 
uint64_t Uint64Value () const
 
double NextPositiveDouble () const
 
bool Sign () const
 
uint64_t Significand () const
 
int Exponent () const
 
bool IsNan () const
 
bool IsInf () const
 
bool IsNanOrInf () const
 
bool IsNormal () const
 
bool IsZero () const
 
uint64_t IntegerSignificand () const
 
int IntegerExponent () const
 
uint64_t ToBias () const
 

Static Public Member Functions

static int EffectiveSignificandSize (int order)
 

Private Attributes

union {
   double   d_
 
   uint64_t   u_
 
}; 
 

Static Private Attributes

static const int kSignificandSize = 52
 
static const int kExponentBias = 0x3FF
 
static const int kDenormalExponent = 1 - kExponentBias
 
static const uint64_t kSignMask = RAPIDJSON_UINT64_C2(0x80000000, 0x00000000)
 
static const uint64_t kExponentMask = RAPIDJSON_UINT64_C2(0x7FF00000, 0x00000000)
 
static const uint64_t kSignificandMask = RAPIDJSON_UINT64_C2(0x000FFFFF, 0xFFFFFFFF)
 
static const uint64_t kHiddenBit = RAPIDJSON_UINT64_C2(0x00100000, 0x00000000)
 

Detailed Description

Definition at line 23 of file ieee754.h.

Constructor & Destructor Documentation

internal::Double::Double ( )
inline

Definition at line 25 of file ieee754.h.

25 {}
internal::Double::Double ( double  d)
inline

Definition at line 26 of file ieee754.h.

26 : d_(d) {}
internal::Double::Double ( uint64_t  u)
inline

Definition at line 27 of file ieee754.h.

27 : u_(u) {}
uint64_t u_
Definition: ieee754.h:71

Member Function Documentation

static int internal::Double::EffectiveSignificandSize ( int  order)
inlinestatic

Definition at line 51 of file ieee754.h.

51  {
52  if (order >= -1021)
53  return 53;
54  else if (order <= -1074)
55  return 0;
56  else
57  return order + 1074;
58  }
int internal::Double::Exponent ( ) const
inline

Definition at line 39 of file ieee754.h.

39 { return static_cast<int>(((u_ & kExponentMask) >> kSignificandSize) - kExponentBias); }
static const int kSignificandSize
Definition: ieee754.h:61
uint64_t u_
Definition: ieee754.h:71
static const uint64_t kExponentMask
Definition: ieee754.h:65
static const int kExponentBias
Definition: ieee754.h:62
int internal::Double::IntegerExponent ( ) const
inline

Definition at line 48 of file ieee754.h.

static const int kSignificandSize
Definition: ieee754.h:61
bool IsNormal() const
Definition: ieee754.h:44
static const int kDenormalExponent
Definition: ieee754.h:63
int Exponent() const
Definition: ieee754.h:39
uint64_t internal::Double::IntegerSignificand ( ) const
inline

Definition at line 47 of file ieee754.h.

47 { return IsNormal() ? Significand() | kHiddenBit : Significand(); }
uint64_t Significand() const
Definition: ieee754.h:38
bool IsNormal() const
Definition: ieee754.h:44
static const uint64_t kHiddenBit
Definition: ieee754.h:67
bool internal::Double::IsInf ( ) const
inline

Definition at line 42 of file ieee754.h.

42 { return (u_ & kExponentMask) == kExponentMask && Significand() == 0; }
uint64_t u_
Definition: ieee754.h:71
static const uint64_t kExponentMask
Definition: ieee754.h:65
uint64_t Significand() const
Definition: ieee754.h:38
bool internal::Double::IsNan ( ) const
inline

Definition at line 41 of file ieee754.h.

41 { return (u_ & kExponentMask) == kExponentMask && Significand() != 0; }
uint64_t u_
Definition: ieee754.h:71
static const uint64_t kExponentMask
Definition: ieee754.h:65
uint64_t Significand() const
Definition: ieee754.h:38
bool internal::Double::IsNanOrInf ( ) const
inline

Definition at line 43 of file ieee754.h.

43 { return (u_ & kExponentMask) == kExponentMask; }
uint64_t u_
Definition: ieee754.h:71
static const uint64_t kExponentMask
Definition: ieee754.h:65
bool internal::Double::IsNormal ( ) const
inline

Definition at line 44 of file ieee754.h.

44 { return (u_ & kExponentMask) != 0 || Significand() == 0; }
uint64_t u_
Definition: ieee754.h:71
static const uint64_t kExponentMask
Definition: ieee754.h:65
uint64_t Significand() const
Definition: ieee754.h:38
bool internal::Double::IsZero ( ) const
inline

Definition at line 45 of file ieee754.h.

45 { return (u_ & (kExponentMask | kSignificandMask)) == 0; }
uint64_t u_
Definition: ieee754.h:71
static const uint64_t kExponentMask
Definition: ieee754.h:65
static const uint64_t kSignificandMask
Definition: ieee754.h:66
double internal::Double::NextPositiveDouble ( ) const
inline

Definition at line 32 of file ieee754.h.

32  {
34  return Double(u_ + 1).Value();
35  }
uint64_t u_
Definition: ieee754.h:71
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:406
bool Sign() const
Definition: ieee754.h:37
bool internal::Double::Sign ( ) const
inline

Definition at line 37 of file ieee754.h.

37 { return (u_ & kSignMask) != 0; }
uint64_t u_
Definition: ieee754.h:71
static const uint64_t kSignMask
Definition: ieee754.h:64
uint64_t internal::Double::Significand ( ) const
inline

Definition at line 38 of file ieee754.h.

38 { return u_ & kSignificandMask; }
uint64_t u_
Definition: ieee754.h:71
static const uint64_t kSignificandMask
Definition: ieee754.h:66
uint64_t internal::Double::ToBias ( ) const
inline

Definition at line 49 of file ieee754.h.

49 { return (u_ & kSignMask) ? ~u_ + 1 : u_ | kSignMask; }
uint64_t u_
Definition: ieee754.h:71
static const uint64_t kSignMask
Definition: ieee754.h:64
uint64_t internal::Double::Uint64Value ( ) const
inline

Definition at line 30 of file ieee754.h.

30 { return u_; }
uint64_t u_
Definition: ieee754.h:71
double internal::Double::Value ( ) const
inline

Definition at line 29 of file ieee754.h.

29 { return d_; }

Member Data Documentation

union { ... }
double internal::Double::d_

Definition at line 70 of file ieee754.h.

const int internal::Double::kDenormalExponent = 1 - kExponentBias
staticprivate

Definition at line 63 of file ieee754.h.

const int internal::Double::kExponentBias = 0x3FF
staticprivate

Definition at line 62 of file ieee754.h.

const uint64_t internal::Double::kExponentMask = RAPIDJSON_UINT64_C2(0x7FF00000, 0x00000000)
staticprivate

Definition at line 65 of file ieee754.h.

const uint64_t internal::Double::kHiddenBit = RAPIDJSON_UINT64_C2(0x00100000, 0x00000000)
staticprivate

Definition at line 67 of file ieee754.h.

const uint64_t internal::Double::kSignificandMask = RAPIDJSON_UINT64_C2(0x000FFFFF, 0xFFFFFFFF)
staticprivate

Definition at line 66 of file ieee754.h.

const int internal::Double::kSignificandSize = 52
staticprivate

Definition at line 61 of file ieee754.h.

const uint64_t internal::Double::kSignMask = RAPIDJSON_UINT64_C2(0x80000000, 0x00000000)
staticprivate

Definition at line 64 of file ieee754.h.

uint64_t internal::Double::u_

Definition at line 71 of file ieee754.h.


The documentation for this class was generated from the following file: