1 #ifndef MSP_DATAFILE_BINFLOAT_H_
2 #define MSP_DATAFILE_BINFLOAT_H_
12 Facilitates splitting floating-point numbers into parts and putting them back
13 together. Supports arbitary sizes up to 64 bits. The 16, 32 and 64 bit
14 formats exactly match those defined by ISO/IEC 60559:2011.
16 The exponent is stored in an unbiased form. The mantissa is stored with the
17 integer part included, aligned to the high bits of a 64-bit integer.
38 std::uint64_t mantissa;
40 static BinFloat explode(std::uint64_t, const Bits &);
43 static BinFloat explode_iec559(T v);
45 std::uint64_t compose(const Bits &);
52 struct BinFloat::MatchingInt<float> { typedef std::uint32_t Type; };
55 struct BinFloat::MatchingInt<double> { typedef std::uint64_t Type; };
58 union BinFloat::Conversion
61 typename MatchingInt<T>::Type i;
65 inline BinFloat BinFloat::explode_iec559(T v)
69 return explode(c.i, sizeof(T)*CHAR_BIT);
73 inline T BinFloat::compose_iec559()
76 c.i = compose(sizeof(T)*CHAR_BIT);
80 } // namespace DataFile