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:
parent
05b330906e
commit
2d695e3c7c
1 changed files with 30 additions and 8 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue