Skip to content

Commit

Permalink
Move division impl. into intx::internal namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
chfast committed Jun 17, 2020
1 parent 189da7c commit b0faa72
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/intx/div.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace intx
{
namespace
namespace internal
{
/// Divides arbitrary long unsigned integer by 64-bit unsigned integer (1 word).
/// @param u The array of a normalized numerator words. It will contain
Expand Down Expand Up @@ -129,7 +129,7 @@ void udivrem_knuth(uint64_t q[], uint64_t u[], int ulen, const uint64_t d[], int
}
}

} // namespace
} // namespace internal

template <unsigned N>
div_result<uint<N>> udivrem(const uint<N>& u, const uint<N>& v) noexcept
Expand All @@ -141,23 +141,23 @@ div_result<uint<N>> udivrem(const uint<N>& u, const uint<N>& v) noexcept

if (na.num_divisor_words == 1)
{
auto r =
udivrem_by1(as_words(na.numerator), na.num_numerator_words, as_words(na.divisor)[0]);
const auto r = internal::udivrem_by1(
as_words(na.numerator), na.num_numerator_words, as_words(na.divisor)[0]);
return {na.numerator, r >> na.shift};
}

if (na.num_divisor_words == 2)
{
auto d = as_words(na.divisor);
auto r = udivrem_by2(as_words(na.numerator), na.num_numerator_words, {d[1], d[0]});
const auto d = as_words(na.divisor);
const auto r =
internal::udivrem_by2(as_words(na.numerator), na.num_numerator_words, {d[1], d[0]});
return {na.numerator, r >> na.shift};
}

auto un = as_words(na.numerator); // Will be modified.

uint<N> q;

udivrem_knuth(
internal::udivrem_knuth(
as_words(q), &un[0], na.num_numerator_words, as_words(na.divisor), na.num_divisor_words);

uint<N> r;
Expand Down

0 comments on commit b0faa72

Please sign in to comment.