COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
Public Types | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
FloatingPoint< RawType > Class Template Reference

#include <FloatingPoint.hpp>

Public Types

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

Public Member Functions

 FloatingPoint (const RawType &x)
 
bool almost_equals (const FloatingPoint &rhs, const size_t ulps) const
 
bool almost_equals (const FloatingPoint &rhs) const
 
bool is_nan () const
 checking for NaN to match == behavior. More...
 
Bits diff (const FloatingPoint &rhs)
 

Static Public Attributes

static const size_t kBitCount = 8*sizeof(RawType)
 
static const size_t kFracBitCount = std::numeric_limits<RawType>::digits - 1
 
static const size_t kExpBitCount = kBitCount - 1 - kFracBitCount
 
static const Bits kSignBitMask = static_cast<Bits>(1) << (kBitCount - 1)
 
static const Bits kFracBitMask = ~static_cast<Bits>(0) >> (kExpBitCount + 1)
 
static const Bits kExpBitMask = ~(kSignBitMask | kFracBitMask)
 
static const size_t kMaxUlps = 4
 

Private Member Functions

Bits ulp_diff (const Bits &sam1, const Bits &sam2) const
 
Bits SignAndMagnitudeToBiased (const Bits &sam) const
 

Private Attributes

union {
   RawType   value_
 
   Bits   bits_
 
}; 
 

Detailed Description

template<typename RawType>
class cf3::math::FloatingPoint< RawType >

See also
article "Comparing floating point numbers" by Bruce Dawson for the rationale

Definition at line 83 of file FloatingPoint.hpp.

Member Typedef Documentation

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

Definition at line 86 of file FloatingPoint.hpp.

Constructor & Destructor Documentation

FloatingPoint ( const RawType &  x)
inlineexplicit

Definition at line 98 of file FloatingPoint.hpp.

Member Function Documentation

bool almost_equals ( const FloatingPoint< RawType > &  rhs,
const size_t  ulps 
) const
inline

Definition at line 100 of file FloatingPoint.hpp.

bool almost_equals ( const FloatingPoint< RawType > &  rhs) const
inline

Definition at line 106 of file FloatingPoint.hpp.

Bits diff ( const FloatingPoint< RawType > &  rhs)
inline

Definition at line 118 of file FloatingPoint.hpp.

bool is_nan ( ) const
inline

checking for NaN to match == behavior.

Definition at line 112 of file FloatingPoint.hpp.

Bits SignAndMagnitudeToBiased ( const Bits sam) const
inlineprivate

Definition at line 133 of file FloatingPoint.hpp.

Bits ulp_diff ( const Bits sam1,
const Bits sam2 
) const
inlineprivate

Definition at line 125 of file FloatingPoint.hpp.

Member Data Documentation

union { ... }
Bits bits_

Definition at line 145 of file FloatingPoint.hpp.

const size_t kBitCount = 8*sizeof(RawType)
static

Definition at line 88 of file FloatingPoint.hpp.

const size_t kExpBitCount = kBitCount - 1 - kFracBitCount
static

Definition at line 90 of file FloatingPoint.hpp.

const Bits kExpBitMask = ~(kSignBitMask | kFracBitMask)
static

Definition at line 94 of file FloatingPoint.hpp.

const size_t kFracBitCount = std::numeric_limits<RawType>::digits - 1
static

Definition at line 89 of file FloatingPoint.hpp.

const Bits kFracBitMask = ~static_cast<Bits>(0) >> (kExpBitCount + 1)
static

Definition at line 93 of file FloatingPoint.hpp.

const size_t kMaxUlps = 4
static

Definition at line 96 of file FloatingPoint.hpp.

const Bits kSignBitMask = static_cast<Bits>(1) << (kBitCount - 1)
static

Definition at line 92 of file FloatingPoint.hpp.

RawType value_

Definition at line 144 of file FloatingPoint.hpp.


The documentation for this class was generated from the following file:
Send comments to:
COOLFluiD Web Admin