Skip to content
Snippets Groups Projects
Commit 3e8281ea authored by John Romein's avatar John Romein
Browse files

Fixed sign extension.

parent b283c750
No related branches found
No related tags found
No related merge requests found
...@@ -10,8 +10,8 @@ class complex_int4_t ...@@ -10,8 +10,8 @@ class complex_int4_t
complex_int4_t() {} complex_int4_t() {}
complex_int4_t(int real, int imag) { value = (imag << 4) | (real & 0xF); } 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; } 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 real() const { return (signed) value << (std::numeric_limits<unsigned>::digits - 4) >> (std::numeric_limits<unsigned>::digits - 4); }
int imag() const { return value << (std::numeric_limits<int>::digits - 8) >> (std::numeric_limits<int>::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()); } operator std::complex<int> () const { return std::complex<int>(real(), imag()); }
private: private:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment