diff --git a/src/mp/int.hpp b/src/mp/int.hpp index 662782a..f5cfd01 100644 --- a/src/mp/int.hpp +++ b/src/mp/int.hpp @@ -1,7 +1,5 @@ #pragma once -#include - #include "storage.hpp" #include "utils.hpp" @@ -220,7 +218,6 @@ private: template using Int = BasicInt; -constexpr size_t UNLIMITED = std::numeric_limits::max(); using UnlimitedInt = BasicInt; } // namespace mp \ No newline at end of file diff --git a/src/mp/math.hpp b/src/mp/math.hpp index f481048..65eaecf 100644 --- a/src/mp/math.hpp +++ b/src/mp/math.hpp @@ -351,13 +351,13 @@ struct Division const LongerType MASK = BASE - 1; // Prepare u (normalized dividend) length m + n + 1 - BasicInt u; + BasicInt u; u.zero(); for (size_t i = 0; i < lhs.size_elems(); ++i) u.set(i, lhs.get(i)); // Prepare v (normalized divisor) length n - BasicInt v; + BasicInt v; v.zero(); for (size_t i = 0; i < n; ++i) v.set(i, rhs.get(i)); diff --git a/src/mp/utils.hpp b/src/mp/utils.hpp index d152bfc..1925175 100644 --- a/src/mp/utils.hpp +++ b/src/mp/utils.hpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #ifdef __SIZEOF_INT128__ @@ -137,4 +138,14 @@ constexpr TElem calculate_last_elem_mask() return mask; } +constexpr size_t UNLIMITED = std::numeric_limits::max(); + +constexpr size_t calculate_sum_bytes(size_t bytes_a, size_t bytes_b) +{ + if (bytes_a == UNLIMITED || bytes_b == UNLIMITED) + return UNLIMITED; + + return bytes_a + bytes_b; +} + } // namespace mp \ No newline at end of file