12 namespace duds {
namespace data {
15 const std::uint32_t &oi = *(std::uint32_t*)(&o);
16 int temp = ((oi >> 23) & 0xFF) - 127;
17 if ((temp > 62) || (temp < -63)) {
21 sign = oi >= (1 << 31);
22 mant = (oi & 0x7FFFFF) >> 3;
26 std::uint32_t oo = (
mant << 3) | ((
exp + 127) << 23) | (
sign << 31);
27 return *((
float*)(&oo));
31 const std::uint64_t &oi = *(std::uint64_t*)(&o);
32 int temp = ((oi >> 52) & 0x7FF) - 1023;
33 if ((temp > 62) || (temp < -63)) {
37 sign = oi >= ((std::uint64_t)1 << 63);
38 mant = (oi & (std::uint64_t)0xFFFFFFFFFFFFF) >> 32;
42 std::uint64_t oo = ((std::uint64_t)
mant << 32) |
43 ((std::uint64_t)(
exp + 1023) << 52) | ((std::uint64_t)
sign << 63);
44 return *((
double*)(&oo));
Indicates that a value is beyond the range allowed by the Unit or ExtendedUnit class.
ExtendedUnit()=default
Makes an uninitialized ExtendedUnit.
ExtendedUnit & operator*=(const Unit &U)
Combines two units into a new unit.
ExtendedUnit & operator=(const Unit &U)
Makes this extended unit equivalent to the given Unit object.
const ExtendedUnit operator*(const Unit &U) const
Combines two units into a new unit.
std::int32_t value() const
Returns the internal exponent fields.
unsigned int mant
The mantissa, save for the impled leading bit.
const ExtendedUnit operator/(const Unit &U) const
Combines two units into a new unit.
Represents an SI unit, either base or derived.
ExtendedUnit & operator/=(const Unit &U)
Combines two units into a new unit.
boost::error_info< struct Info_unitexp, int > BadUnitExponent
The out-of-range exponent.
redo: Use floats for scale and offset.
float offsetf() const
Query the offset as a float.
int exp
The exponent as a signed integer rather than unsigned with bias.
double offset() const
Query the offset as a double.
#define DUDS_THROW_EXCEPTION(x)
Works like BOOST_THROW_EXCEPTION, but includes a stack trace if DUDS_ERRORS_VERBOSE is defined...
std::uint32_t scaloff
A scaling and offset value packed into four bytes.