Skip to content

Commit

Permalink
Type consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
WrathfulSpatula committed Jan 2, 2025
1 parent bd10e5d commit 12a480f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Eratosthenes/_eratosthenes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

namespace qimcifa {

DispatchQueue dispatch(std::thread::hardware_concurrency());

typedef boost::multiprecision::cpp_int BigInteger;

inline BigInteger sqrt(const BigInteger& toTest)
Expand Down Expand Up @@ -80,7 +82,7 @@ inline BigInteger forward5(const size_t& p) {
}

inline size_t backward5(const BigInteger &n) {
return (size_t)(std::distance(wheel5, std::lower_bound(wheel5, wheel5 + 8U, n % 30U)) + 8U * (n / 30U) + 1U);
return std::distance(wheel5, std::lower_bound(wheel5, wheel5 + 8U, (size_t)(n % 30U))) + 8U * (size_t)(n / 30U) + 1U;
}

constexpr unsigned char wheel7[48U] = {
Expand All @@ -94,7 +96,7 @@ inline BigInteger forward7(const size_t& p) {
}

inline size_t backward7(const BigInteger& n) {
return (size_t)(std::distance(wheel7, std::lower_bound(wheel7, wheel7 + 48U, n % 210U)) + 48U * (n / 210U) + 1U);
return std::distance(wheel7, std::lower_bound(wheel7, wheel7 + 48U, (size_t)(n % 210U))) + 48U * (size_t)(n / 210U) + 1U;
}

constexpr unsigned short wheel11[480U] = {
Expand Down Expand Up @@ -125,11 +127,9 @@ inline BigInteger forward11(const size_t &p) {
}

inline size_t backward11(const BigInteger &n) {
return std::distance(wheel11, std::lower_bound(wheel11, wheel11 + 480U, size_t(n % 2310U))) + 480U * (size_t)(n / 2310U) + 1U;
return std::distance(wheel11, std::lower_bound(wheel11, wheel11 + 480U, (size_t)(n % 2310U))) + 480U * (size_t)(n / 2310U) + 1U;
}

DispatchQueue dispatch(std::thread::hardware_concurrency());

std::vector<BigInteger> SieveOfEratosthenes(const BigInteger& n)
{
std::vector<BigInteger> knownPrimes = { 2U, 3U, 5U, 7U, 11U };
Expand Down

0 comments on commit 12a480f

Please sign in to comment.