7template<u
int32_t DIVISOR>
11 uint64_t rd = dividend / DIVISOR;
12 if (uint32_t(rd) == rd) {
13 CHECK(c.
div(dividend) == (dividend / DIVISOR));
14 CHECK(s.
div(dividend) == (dividend / DIVISOR));
15 CHECK(c.
mod(dividend) == (dividend % DIVISOR));
16 CHECK(s.
mod(dividend) == (dividend % DIVISOR));
20template<u
int32_t DIVISOR>
26 for (uint64_t dividend : {0ULL, 1ULL, 2ULL, 3ULL, 4ULL, 5ULL, 7ULL,
27 100ULL, 10015ULL, 12410015ULL, 0x1234567890ULL,
28 0x7FFFFFFFFFFFFFFFULL, 0x8000000000000000ULL,
29 0xFFFFFFFF00000000ULL, 0xFFFFFFFFFFFFFFFFULL}) {
TEST_CASE("DivModByConst, DivModBySame")
Helper class to divide multiple times by the same number.
uint32_t div(uint64_t dividend) const
uint32_t mod(uint64_t dividend) const
void setDivisor(uint32_t divisor)
This file implemented 3 utility functions:
constexpr uint32_t div(uint64_t dividend) const
constexpr uint32_t mod(uint64_t dividend) const