From 3e8281ea4aaae5280ec6f959c7889fc47d4a9c47 Mon Sep 17 00:00:00 2001 From: John Romein <romein@astron.nl> Date: Wed, 15 Dec 2021 21:51:28 +0100 Subject: [PATCH] Fixed sign extension. --- test/Common/ComplexInt4.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Common/ComplexInt4.h b/test/Common/ComplexInt4.h index e448428..2cb9c50 100644 --- a/test/Common/ComplexInt4.h +++ b/test/Common/ComplexInt4.h @@ -10,8 +10,8 @@ class complex_int4_t complex_int4_t() {} complex_int4_t(int real, int imag) { value = (imag << 4) | (real & 0xF); } complex_int4_t operator = (const complex_int4_t &other) { value = other.value; return *this; } - int real() const { return value << (std::numeric_limits<int>::digits - 4) >> (std::numeric_limits<int>::digits - 4); } - int imag() const { return value << (std::numeric_limits<int>::digits - 8) >> (std::numeric_limits<int>::digits - 4); } + int real() const { return (signed) value << (std::numeric_limits<unsigned>::digits - 4) >> (std::numeric_limits<unsigned>::digits - 4); } + int imag() const { return (signed) value << (std::numeric_limits<unsigned>::digits - 8) >> (std::numeric_limits<unsigned>::digits - 4); } operator std::complex<int> () const { return std::complex<int>(real(), imag()); } private: -- GitLab