diff --git a/ciphers/uint128_t.hpp b/ciphers/uint128_t.hpp index 993ef6683..c1e7b7876 100644 --- a/ciphers/uint128_t.hpp +++ b/ciphers/uint128_t.hpp @@ -688,7 +688,7 @@ class uint128_t { return *this; } - uint128_t operator&(const uint128_t &p) { + inline uint128_t operator&(const uint128_t &p) { return uint128_t(this->f & p.f, this->s & p.s); } @@ -714,11 +714,11 @@ class uint128_t { template ::value, T>::type> - uint128_t operator|(const T p) { + inline uint128_t operator|(const T p) { return uint128_t(p | s); } - uint128_t operator|(const uint128_t &p) { + inline uint128_t operator|(const uint128_t &p) { return uint128_t(this->f | p.f, this->s | p.s); } @@ -730,18 +730,18 @@ class uint128_t { template ::value, T>::type> - uint128_t &operator|=(const T p) { + inline uint128_t &operator|=(const T p) { s |= p.s; return *this; } template ::value, T>::type> - uint128_t operator^(const T p) { + inline uint128_t operator^(const T p) { return uint128_t(this->f, this->s ^ p); } - uint128_t operator^(const uint128_t &p) { + inline uint128_t operator^(const uint128_t &p) { return uint128_t(this->f ^ p.f, this->s ^ p.s); } @@ -753,7 +753,7 @@ class uint128_t { template ::value, T>::type> - uint128_t &operator^=(const T &p) { + inline uint128_t &operator^=(const T &p) { s ^= p; return *this; } @@ -787,100 +787,100 @@ class uint128_t { // Arithmetic operators template ::value, T>::type> -uint128_t operator+(const T &p, const uint128_t &q) { +inline uint128_t operator+(const T &p, const uint128_t &q) { return uint128_t(p) + q; } template ::value, T>::type> -uint128_t operator-(const T p, const uint128_t &q) { +inline uint128_t operator-(const T p, const uint128_t &q) { return uint128_t(p) - q; } template ::value, T>::type> -uint128_t operator*(const T p, const uint128_t &q) { - return q * p; +inline uint128_t operator*(const T p, const uint128_t &q) { + return uint128_t(p) * q; } template ::value, T>::type> -uint128_t operator/(const T p, const uint128_t &q) { +inline uint128_t operator/(const T p, const uint128_t &q) { return uint128_t(p) / q; } template ::value, T>::type> -uint128_t operator%(const T p, const uint128_t &q) { +inline uint128_t operator%(const T p, const uint128_t &q) { return uint128_t(p) % q; } // Bitwise operators template ::value, T>::type> -uint128_t operator&(const T &p, const uint128_t &q) { +inline uint128_t operator&(const T &p, const uint128_t &q) { return uint128_t(p) & q; } template ::value, T>::type> -uint128_t operator|(const T p, const uint128_t &q) { +inline uint128_t operator|(const T p, const uint128_t &q) { return uint128_t(p) | q; } template ::value, T>::type> -uint128_t operator^(const T p, const uint128_t &q) { +inline uint128_t operator^(const T p, const uint128_t &q) { return uint128_t(p) ^ q; } // Boolean operators template ::value, T>::type> -bool operator&&(const T p, const uint128_t &q) { +inline bool operator&&(const T p, const uint128_t &q) { return uint128_t(p) && q; } template ::value, T>::type> -bool operator||(const T p, const uint128_t &q) { +inline bool operator||(const T p, const uint128_t &q) { return uint128_t(p) || q; } // Comparison operators template ::value, T>::type> -bool operator==(const T p, const uint128_t &q) { +inline bool operator==(const T p, const uint128_t &q) { return uint128_t(p) == q; } template ::value, T>::type> -bool operator!=(const T p, const uint128_t &q) { +inline bool operator!=(const T p, const uint128_t &q) { return uint128_t(p) != q; } template ::value, T>::type> -bool operator<(const T p, const uint128_t &q) { +inline bool operator<(const T p, const uint128_t &q) { return uint128_t(p) < q; } template ::value, T>::type> -bool operator<=(const T p, const uint128_t &q) { +inline bool operator<=(const T p, const uint128_t &q) { return uint128_t(p) <= q; } template ::value, T>::type> -bool operator>(const T p, const uint128_t &q) { +inline bool operator>(const T p, const uint128_t &q) { return uint128_t(p) > q; } template ::value, T>::type> -bool operator>=(const T p, const uint128_t &q) { +inline bool operator>=(const T p, const uint128_t &q) { return uint128_t(p) >= q; } diff --git a/ciphers/uint256_t.hpp b/ciphers/uint256_t.hpp index 04d96b574..b90d7ca93 100644 --- a/ciphers/uint256_t.hpp +++ b/ciphers/uint256_t.hpp @@ -197,8 +197,8 @@ class uint256_t { * @returns addition of this and p, returning uint256_t integer */ inline uint256_t operator+(const uint256_t &p) { - uint32_t app = (s + p.s < s); - return {f + app + p.f, p.s + s}; + bool app = (s + p.s < s); + return uint256_t(f + p.f + app, p.s + s); } /** @@ -210,7 +210,7 @@ class uint256_t { template ::value, T>::type> inline uint256_t &operator+=(const T &p) { - uint32_t app = (p + s < s); + bool app = (p + s < s); this->f += app; this->s += p; return *this; @@ -222,8 +222,8 @@ class uint256_t { * @returns addition of this and p, returning this */ inline uint256_t &operator+=(const uint256_t &p) { - uint32_t _app = (p.s + s < s); - f += _app + p.f; + bool app = (p.s + s < s); + f += app + p.f; s += p.s; return *this; } @@ -255,7 +255,7 @@ class uint256_t { template ::value, T>::type> inline uint256_t operator-(const T &p) { - uint32_t app = (p > s); + bool app = (p > s); return uint256_t(f - app, s - p); } @@ -265,8 +265,8 @@ class uint256_t { * @returns subtraction of this and p, returning uint256_t integer */ inline uint256_t operator-(const uint256_t &p) { - uint32_t app = p.s > s; - return {f - p.f - app, s - p.s}; + bool app = p.s > s; + return uint256_t(f - p.f - app, s - p.s); } /** @@ -302,7 +302,7 @@ class uint256_t { template ::value, T>::type> inline uint256_t operator-=(const T p) { - uint32_t app = (p > s); + bool app = (p > s); f -= app; s -= p; return *this; @@ -314,8 +314,8 @@ class uint256_t { * @returns subtraction of this and p, returning this */ inline uint256_t &operator-=(const uint256_t &p) { - uint32_t app = p.s > s; - f = f - app - p.f; + bool app = p.s > s; + f = f - p.f - app; s -= p.s; return *this; }