CheatSearch: Use two's complement for negative hex values

This commit is contained in:
Dentomologist 2024-04-26 12:23:12 -07:00
parent e69486d2cb
commit 628ab51b4b
1 changed files with 11 additions and 3 deletions

View File

@ -572,11 +572,19 @@ std::string Cheats::CheatSearchSession<T>::GetResultValueAsString(size_t index,
if (hex)
{
if constexpr (std::is_same_v<T, float>)
return fmt::format("0x{0:08x}", Common::BitCast<u32>(m_search_results[index].m_value));
{
return fmt::format("0x{0:08x}", Common::BitCast<s32>(m_search_results[index].m_value));
}
else if constexpr (std::is_same_v<T, double>)
return fmt::format("0x{0:016x}", Common::BitCast<u64>(m_search_results[index].m_value));
{
return fmt::format("0x{0:016x}", Common::BitCast<s64>(m_search_results[index].m_value));
}
else
return fmt::format("0x{0:0{1}x}", m_search_results[index].m_value, sizeof(T) * 2);
{
return fmt::format("0x{0:0{1}x}",
Common::BitCast<std::make_unsigned_t<T>>(m_search_results[index].m_value),
sizeof(T) * 2);
}
}
return fmt::format("{}", m_search_results[index].m_value);