1 #ifndef __STDAIR_BAS_FLOAT_UTILS_GOOGLE_HPP
2 #define __STDAIR_BAS_FLOAT_UTILS_GOOGLE_HPP
53 template <
size_t size>
79 typedef unsigned __int64
UInt;
81 typedef long long Int;
82 typedef unsigned long long UInt;
116 template <
typename RawType>
130 std::numeric_limits<RawType>::digits - 1;
215 return DistanceBetweenSignAndMagnitudeNumbers(u_.bits_, rhs.u_.bits_)
221 union FloatingPointUnion {
241 static Bits SignAndMagnitudeToBiased(
const Bits &sam) {
253 static Bits DistanceBetweenSignAndMagnitudeNumbers(
const Bits &sam1,
255 const Bits biased1 = SignAndMagnitudeToBiased(sam1);
256 const Bits biased2 = SignAndMagnitudeToBiased(sam2);
257 return (biased1 >= biased2) ? (biased1 - biased2) : (biased2 - biased1);
260 FloatingPointUnion u_;
static const size_t kExponentBitCount
static const Bits kSignBitMask
FloatingPoint(const RawType &x)
bool AlmostEquals(const FloatingPoint &rhs) const
const Bits & bits() const
static const Bits kFractionBitMask
Bits fraction_bits() const
static const Bits kExponentBitMask
static RawType ReinterpretBits(const Bits bits)
TypeWithSize< sizeof(RawType)>::UInt Bits
static RawType Infinity()
Bits exponent_bits() const
static const size_t kMaxUlps
static const size_t kBitCount
static const size_t kFractionBitCount