From e60d6c0d200a089d6b02c6a723897fa0b4000f73 Mon Sep 17 00:00:00 2001 From: MerryMage Date: Thu, 16 Aug 2018 10:50:28 +0100 Subject: [PATCH] fp/info: Incorrect point_position in FPValue --- src/common/fp/info.h | 2 +- tests/CMakeLists.txt | 1 + tests/fp/FPValue.cpp | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 tests/fp/FPValue.cpp diff --git a/src/common/fp/info.h b/src/common/fp/info.h index fc28e924..a56baa2d 100644 --- a/src/common/fp/info.h +++ b/src/common/fp/info.h @@ -68,7 +68,7 @@ constexpr FPT FPValue() { return FPInfo::Zero(sign); } - constexpr int point_position = static_cast(FPInfo::mantissa_width); + constexpr int point_position = static_cast(FPInfo::explicit_mantissa_width); constexpr int highest_bit = Common::HighestSetBit(value); constexpr int offset = point_position - highest_bit; constexpr int normalized_exponent = exponent - offset + point_position; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 6e645862..92d15ffd 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -29,6 +29,7 @@ add_executable(dynarmic_tests A64/testenv.h cpu_info.cpp fp/FPToFixed.cpp + fp/FPValue.cpp fp/mantissa_util_tests.cpp fp/unpacked_tests.cpp main.cpp diff --git a/tests/fp/FPValue.cpp b/tests/fp/FPValue.cpp new file mode 100644 index 00000000..e5c4ee52 --- /dev/null +++ b/tests/fp/FPValue.cpp @@ -0,0 +1,15 @@ +/* This file is part of the dynarmic project. + * Copyright (c) 2018 MerryMage + * This software may be used and distributed according to the terms of the GNU + * General Public License version 2 or any later version. + */ + +#include "common/fp/info.h" + +using namespace Dynarmic::FP; + +static_assert(FPValue() == 0x3f800000); +static_assert(FPValue() == 0x3fc00000); +static_assert(FPValue() == 0x4b4264e4); +static_assert(FPValue() == 0x3ec80000); +static_assert(FPValue() == 0xbf800000);