Merge pull request #12742 from Dentomologist/cheatsearch_use_twos_complement_for_negative_hex_values

CheatSearch: Use two's complement for negative hex values
This commit is contained in:
Admiral H. Curtiss 2024-04-28 20:12:14 +02:00 committed by GitHub
commit 9d87c82d8a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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);