Electroneum
testing::internal::FloatingPoint< RawType > Class Template Reference

#include <gtest-internal.h>

Collaboration diagram for testing::internal::FloatingPoint< RawType >:

Public Types

typedef TypeWithSize< sizeof(RawType)>::UInt Bits
 
typedef TypeWithSize< sizeof(RawType)>::UInt Bits
 

Public Member Functions

 FloatingPoint (const RawType &x)
 
const Bitsbits () const
 
Bits exponent_bits () const
 
Bits fraction_bits () const
 
Bits sign_bit () const
 
bool is_nan () const
 
bool AlmostEquals (const FloatingPoint &rhs) const
 
 FloatingPoint (const RawType &x)
 
const Bitsbits () const
 
Bits exponent_bits () const
 
Bits fraction_bits () const
 
Bits sign_bit () const
 
bool is_nan () const
 
bool AlmostEquals (const FloatingPoint &rhs) const
 
template<>
float Max ()
 
template<>
double Max ()
 
template<>
float Max ()
 
template<>
double Max ()
 

Static Public Member Functions

static RawType ReinterpretBits (const Bits bits)
 
static RawType Infinity ()
 
static RawType Max ()
 
static RawType ReinterpretBits (const Bits bits)
 
static RawType Infinity ()
 
static RawType Max ()
 

Static Public Attributes

static const size_t kBitCount = 8*sizeof(RawType)
 
static const size_t kFractionBitCount
 
static const size_t kExponentBitCount = kBitCount - 1 - kFractionBitCount
 
static const Bits kSignBitMask = static_cast<Bits>(1) << (kBitCount - 1)
 
static const Bits kFractionBitMask
 
static const Bits kExponentBitMask = ~(kSignBitMask | kFractionBitMask)
 
static const size_t kMaxUlps = 4
 

Detailed Description

template<typename RawType>
class testing::internal::FloatingPoint< RawType >

Definition at line 262 of file gtest-internal.h.

Member Typedef Documentation

◆ Bits [1/2]

template<typename RawType>
typedef TypeWithSize<sizeof(RawType)>::UInt testing::internal::FloatingPoint< RawType >::Bits

Definition at line 266 of file gtest-internal.h.

◆ Bits [2/2]

template<typename RawType>
typedef TypeWithSize<sizeof(RawType)>::UInt testing::internal::FloatingPoint< RawType >::Bits

Definition at line 266 of file gtest-internal.h.

Constructor & Destructor Documentation

◆ FloatingPoint() [1/2]

template<typename RawType>
testing::internal::FloatingPoint< RawType >::FloatingPoint ( const RawType &  x)
inlineexplicit

Definition at line 310 of file gtest-internal.h.

310 { u_.value_ = x; }

◆ FloatingPoint() [2/2]

template<typename RawType>
testing::internal::FloatingPoint< RawType >::FloatingPoint ( const RawType &  x)
inlineexplicit

Definition at line 310 of file gtest-internal.h.

310 { u_.value_ = x; }

Member Function Documentation

◆ AlmostEquals() [1/2]

template<typename RawType>
bool testing::internal::FloatingPoint< RawType >::AlmostEquals ( const FloatingPoint< RawType > &  rhs) const
inline

Definition at line 358 of file gtest-internal.h.

358  {
359  // The IEEE standard says that any comparison operation involving
360  // a NAN must return false.
361  if (is_nan() || rhs.is_nan()) return false;
362 
363  return DistanceBetweenSignAndMagnitudeNumbers(u_.bits_, rhs.u_.bits_)
364  <= kMaxUlps;
365  }
Here is the call graph for this function:

◆ AlmostEquals() [2/2]

template<typename RawType>
bool testing::internal::FloatingPoint< RawType >::AlmostEquals ( const FloatingPoint< RawType > &  rhs) const
inline

Definition at line 358 of file gtest-internal.h.

358  {
359  // The IEEE standard says that any comparison operation involving
360  // a NAN must return false.
361  if (is_nan() || rhs.is_nan()) return false;
362 
363  return DistanceBetweenSignAndMagnitudeNumbers(u_.bits_, rhs.u_.bits_)
364  <= kMaxUlps;
365  }
Here is the call graph for this function:

◆ bits() [1/2]

template<typename RawType>
const Bits& testing::internal::FloatingPoint< RawType >::bits ( ) const
inline

Definition at line 334 of file gtest-internal.h.

334 { return u_.bits_; }
Here is the caller graph for this function:

◆ bits() [2/2]

template<typename RawType>
const Bits& testing::internal::FloatingPoint< RawType >::bits ( ) const
inline

Definition at line 334 of file gtest-internal.h.

334 { return u_.bits_; }

◆ exponent_bits() [1/2]

template<typename RawType>
Bits testing::internal::FloatingPoint< RawType >::exponent_bits ( ) const
inline

Definition at line 337 of file gtest-internal.h.

337 { return kExponentBitMask & u_.bits_; }
Here is the caller graph for this function:

◆ exponent_bits() [2/2]

template<typename RawType>
Bits testing::internal::FloatingPoint< RawType >::exponent_bits ( ) const
inline

Definition at line 337 of file gtest-internal.h.

337 { return kExponentBitMask & u_.bits_; }

◆ fraction_bits() [1/2]

template<typename RawType>
Bits testing::internal::FloatingPoint< RawType >::fraction_bits ( ) const
inline

Definition at line 340 of file gtest-internal.h.

340 { return kFractionBitMask & u_.bits_; }
Here is the caller graph for this function:

◆ fraction_bits() [2/2]

template<typename RawType>
Bits testing::internal::FloatingPoint< RawType >::fraction_bits ( ) const
inline

Definition at line 340 of file gtest-internal.h.

340 { return kFractionBitMask & u_.bits_; }

◆ Infinity() [1/2]

template<typename RawType>
static RawType testing::internal::FloatingPoint< RawType >::Infinity ( )
inlinestatic

Definition at line 324 of file gtest-internal.h.

324  {
326  }
static RawType ReinterpretBits(const Bits bits)
Here is the call graph for this function:

◆ Infinity() [2/2]

template<typename RawType>
static RawType testing::internal::FloatingPoint< RawType >::Infinity ( )
inlinestatic

Definition at line 324 of file gtest-internal.h.

324  {
326  }
static RawType ReinterpretBits(const Bits bits)
Here is the call graph for this function:

◆ is_nan() [1/2]

template<typename RawType>
bool testing::internal::FloatingPoint< RawType >::is_nan ( ) const
inline

Definition at line 346 of file gtest-internal.h.

346  {
347  // It's a NAN if the exponent bits are all ones and the fraction
348  // bits are not entirely zeros.
349  return (exponent_bits() == kExponentBitMask) && (fraction_bits() != 0);
350  }
Here is the call graph for this function:

◆ is_nan() [2/2]

template<typename RawType>
bool testing::internal::FloatingPoint< RawType >::is_nan ( ) const
inline

Definition at line 346 of file gtest-internal.h.

346  {
347  // It's a NAN if the exponent bits are all ones and the fraction
348  // bits are not entirely zeros.
349  return (exponent_bits() == kExponentBitMask) && (fraction_bits() != 0);
350  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Max() [1/6]

template<typename RawType>
static RawType testing::internal::FloatingPoint< RawType >::Max ( )
static

◆ Max() [2/6]

template<typename RawType>
static RawType testing::internal::FloatingPoint< RawType >::Max ( )
static

◆ Max() [3/6]

template<>
float testing::internal::FloatingPoint< float >::Max ( )
inline

Definition at line 414 of file gtest-internal.h.

414 { return FLT_MAX; }

◆ Max() [4/6]

template<>
float testing::internal::FloatingPoint< float >::Max ( )
inline

Definition at line 414 of file gtest-internal.h.

414 { return FLT_MAX; }

◆ Max() [5/6]

template<>
double testing::internal::FloatingPoint< double >::Max ( )
inline

Definition at line 416 of file gtest-internal.h.

416 { return DBL_MAX; }

◆ Max() [6/6]

template<>
double testing::internal::FloatingPoint< double >::Max ( )
inline

Definition at line 416 of file gtest-internal.h.

416 { return DBL_MAX; }

◆ ReinterpretBits() [1/2]

template<typename RawType>
static RawType testing::internal::FloatingPoint< RawType >::ReinterpretBits ( const Bits  bits)
inlinestatic

Definition at line 317 of file gtest-internal.h.

317  {
318  FloatingPoint fp(0);
319  fp.u_.bits_ = bits;
320  return fp.u_.value_;
321  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReinterpretBits() [2/2]

template<typename RawType>
static RawType testing::internal::FloatingPoint< RawType >::ReinterpretBits ( const Bits  bits)
inlinestatic

Definition at line 317 of file gtest-internal.h.

317  {
318  FloatingPoint fp(0);
319  fp.u_.bits_ = bits;
320  return fp.u_.value_;
321  }
Here is the call graph for this function:

◆ sign_bit() [1/2]

template<typename RawType>
Bits testing::internal::FloatingPoint< RawType >::sign_bit ( ) const
inline

Definition at line 343 of file gtest-internal.h.

343 { return kSignBitMask & u_.bits_; }

◆ sign_bit() [2/2]

template<typename RawType>
Bits testing::internal::FloatingPoint< RawType >::sign_bit ( ) const
inline

Definition at line 343 of file gtest-internal.h.

343 { return kSignBitMask & u_.bits_; }

Member Data Documentation

◆ kBitCount

template<typename RawType>
static const size_t testing::internal::FloatingPoint< RawType >::kBitCount = 8*sizeof(RawType)
static

Definition at line 271 of file gtest-internal.h.

◆ kExponentBitCount

template<typename RawType>
static const size_t testing::internal::FloatingPoint< RawType >::kExponentBitCount = kBitCount - 1 - kFractionBitCount
static

Definition at line 278 of file gtest-internal.h.

◆ kExponentBitMask

template<typename RawType>
static const Bits testing::internal::FloatingPoint< RawType >::kExponentBitMask = ~(kSignBitMask | kFractionBitMask)
static

Definition at line 288 of file gtest-internal.h.

◆ kFractionBitCount

template<typename RawType>
static const size_t testing::internal::FloatingPoint< RawType >::kFractionBitCount
static
Initial value:
=
std::numeric_limits<RawType>::digits - 1

Definition at line 274 of file gtest-internal.h.

◆ kFractionBitMask

template<typename RawType>
static const Bits testing::internal::FloatingPoint< RawType >::kFractionBitMask
static
Initial value:
=
~static_cast<Bits>(0) >> (kExponentBitCount + 1)

Definition at line 284 of file gtest-internal.h.

◆ kMaxUlps

template<typename RawType>
static const size_t testing::internal::FloatingPoint< RawType >::kMaxUlps = 4
static

Definition at line 302 of file gtest-internal.h.

◆ kSignBitMask

template<typename RawType>
static const Bits testing::internal::FloatingPoint< RawType >::kSignBitMask = static_cast<Bits>(1) << (kBitCount - 1)
static

Definition at line 281 of file gtest-internal.h.


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