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;
83 #endif // GTEST_OS_WINDOWS
116 template <
typename RawType>
130 std::numeric_limits<RawType>::digits - 1;
136 static const Bits
kSignBitMask =
static_cast<Bits
>(1) << (kBitCount - 1);
140 ~static_cast<Bits>(0) >> (kExponentBitCount + 1);
186 const Bits &
bits()
const {
return u_.bits_; }
195 Bits
sign_bit()
const {
return kSignBitMask & u_.bits_; }
215 return DistanceBetweenSignAndMagnitudeNumbers(u_.bits_, rhs.u_.bits_)
221 union FloatingPointUnion {
241 static Bits SignAndMagnitudeToBiased(
const Bits &sam) {
242 if (kSignBitMask & sam) {
247 return kSignBitMask | 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_;
263 #endif // __STDAIR_BAS_FLOAT_UTILS_GOOGLE_HPP
static const size_t kBitCount
Bits fraction_bits() const
static RawType ReinterpretBits(const Bits bits)
static const Bits kExponentBitMask
static const size_t kExponentBitCount
static const Bits kSignBitMask
TypeWithSize< sizeof(RawType)>::UInt Bits
Bits exponent_bits() const
static const size_t kMaxUlps
static const size_t kFractionBitCount
static const Bits kFractionBitMask
static RawType Infinity()
bool AlmostEquals(const FloatingPoint &rhs) const
const Bits & bits() const
FloatingPoint(const RawType &x)