///
/// Implemented with one 64-bit integer divide/remainder pair.
///
-/// Returns \c (DigitsT_MAX, INT16_MAX) for divide-by-zero (0 for 0/0).
+/// Returns \c (DigitsT_MAX, MaxScale) for divide-by-zero (0 for 0/0).
template <class DigitsT>
std::pair<DigitsT, int16_t> getQuotient(DigitsT Dividend, DigitsT Divisor) {
static_assert(!std::numeric_limits<DigitsT>::is_signed, "expected unsigned");
if (!Dividend)
return std::make_pair(0, 0);
if (!Divisor)
- return std::make_pair(std::numeric_limits<DigitsT>::max(), INT16_MAX);
+ return std::make_pair(std::numeric_limits<DigitsT>::max(), MaxScale);
if (getWidth<DigitsT>() == 64)
return divide64(Dividend, Divisor);
EXPECT_EQ(SP32(0, 0), getQuotient32(0, 0));
EXPECT_EQ(SP32(0, 0), getQuotient32(0, 1));
EXPECT_EQ(SP32(0, 0), getQuotient32(0, 73));
- EXPECT_EQ(SP32(UINT32_MAX, INT16_MAX), getQuotient32(1, 0));
- EXPECT_EQ(SP32(UINT32_MAX, INT16_MAX), getQuotient32(6, 0));
+ EXPECT_EQ(SP32(UINT32_MAX, MaxScale), getQuotient32(1, 0));
+ EXPECT_EQ(SP32(UINT32_MAX, MaxScale), getQuotient32(6, 0));
// Powers of two.
EXPECT_EQ(SP32(1u << 31, -31), getQuotient32(1, 1));
EXPECT_EQ(SP64(0, 0), getQuotient64(0, 0));
EXPECT_EQ(SP64(0, 0), getQuotient64(0, 1));
EXPECT_EQ(SP64(0, 0), getQuotient64(0, 73));
- EXPECT_EQ(SP64(UINT64_MAX, INT16_MAX), getQuotient64(1, 0));
- EXPECT_EQ(SP64(UINT64_MAX, INT16_MAX), getQuotient64(6, 0));
+ EXPECT_EQ(SP64(UINT64_MAX, MaxScale), getQuotient64(1, 0));
+ EXPECT_EQ(SP64(UINT64_MAX, MaxScale), getQuotient64(6, 0));
// Powers of two.
EXPECT_EQ(SP64(1, 0), getQuotient64(1, 1));