// // This file is part of // // CTBignum // // C++ Library for Compile-Time and Run-Time Multi-Precision and Modular Arithmetic // // // This file is distributed under the Apache License, Version 2.0. See the LICENSE // file for details. #ifndef CT_RELATIONAL_HPP #define CT_RELATIONAL_HPP #include #include #include #include #include namespace cbn { namespace detail { template constexpr bool equal(big_int a, big_int b) { size_t x = 0; for (auto i = 0; i < N; ++i) x += (a[i] != b[i]); return (x == 0); } template constexpr bool less_than(big_int a, big_int b) { return subtract(a, b)[N]; } } // end of detail namespace template constexpr bool operator==(big_int a, big_int b) { constexpr auto L = std::max(N1, N2); return detail::equal(detail::pad(a), detail::pad(b)); } template constexpr bool operator!=(big_int a, big_int b) { return !(a==b); } template constexpr bool operator<(big_int a, big_int b) { constexpr auto L = std::max(N1, N2); return detail::less_than(detail::pad(a), detail::pad(b)); } template constexpr bool operator>(big_int a, big_int b) { return (b < a); } template constexpr bool operator<=(big_int a, big_int b) { return !(b < a); } template constexpr bool operator>=(big_int a, big_int b) { return !(a < b); } } #endif