common/fp/info: Make formatting of FPInfo struct member functions consistent

Orgranizes the functions to all be consistent with the half-precision
specialization.
This commit is contained in:
Lioncash 2019-05-04 21:24:17 -04:00 committed by MerryMage
parent 05b330906e
commit 2d695e3c7c

View file

@ -65,10 +65,21 @@ struct FPInfo<u32> {
static constexpr int exponent_max = 127;
static constexpr int exponent_bias = 127;
static constexpr u32 Zero(bool sign) { return sign ? sign_mask : 0; }
static constexpr u32 Infinity(bool sign) { return exponent_mask | Zero(sign); }
static constexpr u32 MaxNormal(bool sign) { return (exponent_mask - 1) | Zero(sign); }
static constexpr u32 DefaultNaN() { return exponent_mask | (u32(1) << (explicit_mantissa_width - 1)); }
static constexpr u32 Zero(bool sign) {
return sign ? sign_mask : 0;
}
static constexpr u32 Infinity(bool sign) {
return exponent_mask | Zero(sign);
}
static constexpr u32 MaxNormal(bool sign) {
return (exponent_mask - 1) | Zero(sign);
}
static constexpr u32 DefaultNaN() {
return exponent_mask | (u32(1) << (explicit_mantissa_width - 1));
}
};
template<>
@ -88,10 +99,21 @@ struct FPInfo<u64> {
static constexpr int exponent_max = 1023;
static constexpr int exponent_bias = 1023;
static constexpr u64 Zero(bool sign) { return sign ? sign_mask : 0; }
static constexpr u64 Infinity(bool sign) { return exponent_mask | Zero(sign); }
static constexpr u64 MaxNormal(bool sign) { return (exponent_mask - 1) | Zero(sign); }
static constexpr u64 DefaultNaN() { return exponent_mask | (u64(1) << (explicit_mantissa_width - 1)); }
static constexpr u64 Zero(bool sign) {
return sign ? sign_mask : 0;
}
static constexpr u64 Infinity(bool sign) {
return exponent_mask | Zero(sign);
}
static constexpr u64 MaxNormal(bool sign) {
return (exponent_mask - 1) | Zero(sign);
}
static constexpr u64 DefaultNaN() {
return exponent_mask | (u64(1) << (explicit_mantissa_width - 1));
}
};
/// value = (sign ? -1 : +1) * 2^exponent * value