From 03bc2334fe1d5f5fab0456f6d4c7a2101abebf29 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 23 Mar 2019 12:14:08 -0400 Subject: [PATCH] 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. --- src/common/fp/op/FPConvert.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/fp/op/FPConvert.cpp b/src/common/fp/op/FPConvert.cpp index b4e68b7a..8ad3bcc5 100644 --- a/src/common/fp/op/FPConvert.cpp +++ b/src/common/fp/op/FPConvert.cpp @@ -35,7 +35,7 @@ FPT_TO FPConvertNaN(FPT_FROM op) { const u64 exponent = Common::Ones(dest_bit_size - FPInfo::explicit_mantissa_width); 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)) { return FPT_TO(shifted_sign | exponent << 22 | Common::Bits<29, 50>(frac)); } else {