Skip to content

Commit

Permalink
update operator<<= and operator>>= in longint
Browse files Browse the repository at this point in the history
  • Loading branch information
i80287 committed Oct 15, 2024
1 parent f815d33 commit 2b81ee1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions number_theory/longint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1097,13 +1097,13 @@ struct longint {
return this->divmod_impl(n);
}

constexpr longint& operator>>=(std::uint32_t shift) noexcept {
constexpr longint& operator>>=(size_type shift) noexcept {
if ((config::is_constant_evaluated() || config::is_gcc_constant_p(shift)) && shift == 0) {
return *this;
}

size_type usize_value = usize32();
const std::size_t uints_move = shift / kNumsBits;
const size_type uints_move = shift / kNumsBits;
if (uints_move >= usize_value) {
set_zero();
return *this;
Expand Down Expand Up @@ -1137,18 +1137,18 @@ struct longint {

return *this;
}
constexpr longint& operator<<=(std::uint32_t shift) {
constexpr longint& operator<<=(size_type shift) {
if ((config::is_constant_evaluated() || config::is_gcc_constant_p(shift)) && shift == 0) {
return *this;
}

std::size_t usize_value = usize();
size_type usize_value = usize32();
if (usize_value == 0) {
return *this;
}

static_assert(sizeof(digit_t) == sizeof(uint32_t));
const std::uint32_t new_trailig_zeros_digits = shift / kNumsBits;
const size_type new_trailig_zeros_digits = shift / kNumsBits;
// + 1 for potentially new back digit (at the end of the nums_ array)
const auto new_size = usize_value + new_trailig_zeros_digits + 1;
reserve(new_size);
Expand Down

0 comments on commit 2b81ee1

Please sign in to comment.