Helper function for 96/32 signed division, rounding towards negative infinity (if round_down) or positive infinity (if !round_down). This is a fallback version, separate so that it can be tested on platforms where it isn't actually needed.
Declared in <util/feefrac.h>
static
int64_t
DivFallback(
std::pair<int64_t, uint32_t> n,
int32_t d,
bool round_down) noexcept;
The exact behavior with negative n does not really matter, but this implementation chooses to be consistent for testability reasons.
The result must fit in an int64_t, and d must be strictly positive.
The quotient, rounded as requested.
| Name | Description |
|---|---|
| n | The 96-bit signed dividend, encoded as a (high, low) pair. |
| d | The strictly positive 32-bit divisor. |
| round_down | Whether to round towards negative infinity (true) or positive infinity (false). |