8#ifndef SkFloatUtils_DEFINED
9#define SkFloatUtils_DEFINED
34template <
typename RawType>
41 static const int digits = DBL_MANT_DIG;
46 static const int digits = FLT_MANT_DIG;
54template <
typename RawType,
unsigned int ULPs>
61 static const size_t kBitCount = CHAR_BIT *
sizeof(RawType);
117 const Bits dist = DistanceBetweenSignAndMagnitudeNumbers(fU.bits,
125 union FloatingPointUnion {
149 static Bits SignAndMagnitudeToBiased(
const Bits &sam) {
163 static Bits DistanceBetweenSignAndMagnitudeNumbers(
const Bits &sam1,
165 const Bits biased1 = SignAndMagnitudeToBiased(sam1);
166 const Bits biased2 = SignAndMagnitudeToBiased(sam2);
167 return (biased1 >= biased2) ? (biased1 - biased2) : (biased2 - biased1);
170 FloatingPointUnion fU;
SkFloatingPoint(const RawType &x)
static const Bits kFractionBitMask
static const size_t kFractionBitCount
Bits exponent_bits() const
static const Bits kExponentBitMask
static const Bits kSignBitMask
bool AlmostEquals(const SkFloatingPoint &rhs) const
SkTypeWithSize< sizeof(RawType) *CHAR_BIT >::UInt Bits
Bits fraction_bits() const
static const size_t kBitCount
static const size_t kExponentBitCount
static const size_t kMaxUlps