common/fp/op/FPConvert: Amend off-by one in double NaN case in FPConvertNaN

Avoids potentially clobbering the intended sign bit value during
conversions to double-precision values. The other conversion types are
already properly handled, so those don't need to be addressed.
This commit is contained in:
Lioncash 2019-03-23 12:14:08 -04:00 committed by MerryMage
parent c57b146fb2
commit 03bc2334fe

View file

@ -35,7 +35,7 @@ FPT_TO FPConvertNaN(FPT_FROM op) {
const u64 exponent = Common::Ones<u64>(dest_bit_size - FPInfo<FPT_TO>::explicit_mantissa_width); const u64 exponent = Common::Ones<u64>(dest_bit_size - FPInfo<FPT_TO>::explicit_mantissa_width);
if constexpr (sizeof(FPT_TO) == sizeof(u64)) { if constexpr (sizeof(FPT_TO) == sizeof(u64)) {
return FPT_TO(shifted_sign | exponent << 52 | frac); return FPT_TO(shifted_sign | exponent << 51 | frac);
} else if constexpr (sizeof(FPT_TO) == sizeof(u32)) { } else if constexpr (sizeof(FPT_TO) == sizeof(u32)) {
return FPT_TO(shifted_sign | exponent << 22 | Common::Bits<29, 50>(frac)); return FPT_TO(shifted_sign | exponent << 22 | Common::Bits<29, 50>(frac));
} else { } else {