diff options
author | Sven Göthel <[email protected]> | 2024-03-02 21:30:11 +0100 |
---|---|---|
committer | Sven Göthel <[email protected]> | 2024-03-02 21:30:11 +0100 |
commit | 09ae42f5add46dbf15808c6d410ce19597d35ac6 (patch) | |
tree | 893f5f52dae1ea54567852e01fa96ab8ba0d0ac5 /include/jau | |
parent | 373d83e413508c5a66535ff68a0e1b7546f8763d (diff) |
big_int_t: Fix & test free math function wrapper (min, max, clamp ..)
Diffstat (limited to 'include/jau')
-rw-r--r-- | include/jau/mp/big_int_t.hpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/include/jau/mp/big_int_t.hpp b/include/jau/mp/big_int_t.hpp index 81aa8a4..9d91311 100644 --- a/include/jau/mp/big_int_t.hpp +++ b/include/jau/mp/big_int_t.hpp @@ -1557,27 +1557,26 @@ namespace jau { inline mp::big_int_t abs(mp::big_int_t x) noexcept { return x.abs(); } inline mp::big_int_t pow(mp::big_int_t b, mp::big_int_t e) { return b.pow(e); } - constexpr const mp::big_int_t& min(const mp::big_int_t& x, const mp::big_int_t& y) noexcept { + inline const mp::big_int_t& min(const mp::big_int_t& x, const mp::big_int_t& y) noexcept { return x < y ? x : y; } - constexpr const mp::big_int_t& max(const mp::big_int_t& x, const mp::big_int_t& y) noexcept { + inline const mp::big_int_t& max(const mp::big_int_t& x, const mp::big_int_t& y) noexcept { return x > y ? x : y; } - constexpr const mp::big_int_t& clamp(const mp::big_int_t& x, const mp::big_int_t& min_val, const mp::big_int_t& max_val) noexcept { + inline const mp::big_int_t& clamp(const mp::big_int_t& x, const mp::big_int_t& min_val, const mp::big_int_t& max_val) noexcept { return min(max(x, min_val), max_val); } - constexpr mp::big_int_t& min(mp::big_int_t& x, mp::big_int_t& y) noexcept { + inline mp::big_int_t& min(mp::big_int_t& x, mp::big_int_t& y) noexcept { return x < y ? x : y; } - constexpr mp::big_int_t max(mp::big_int_t& x, mp::big_int_t& y) noexcept { + inline mp::big_int_t& max(mp::big_int_t& x, mp::big_int_t& y) noexcept { return x > y ? x : y; } - constexpr mp::big_int_t& clamp(mp::big_int_t& x, mp::big_int_t& min_val, mp::big_int_t& max_val) noexcept { + inline mp::big_int_t& clamp(mp::big_int_t& x, mp::big_int_t& min_val, mp::big_int_t& max_val) noexcept { return min(max(x, min_val), max_val); } - inline mp::big_int_t gcd(const mp::big_int_t& a, const mp::big_int_t& b) noexcept { mp::big_int_t a_ = abs(a); mp::big_int_t b_ = abs(b); @@ -1589,9 +1588,11 @@ namespace jau { return a_; } - std::ostream& operator<<(std::ostream& out, const mp::big_int_t& v) { + /**@}*/ +} + +namespace std { + inline std::ostream& operator<<(std::ostream& out, const jau::mp::big_int_t& v) { return out << v.to_dec_string(); } - - /**@}*/ } |