43 static_assert(std::is_integral_v<T> && !std::is_same_v<T, bool>);
46 if constexpr (std::is_signed_v<T>) {
47 if ((dividend < 0) != (divisor < 0)) {
48 return (dividend - divisor / T{2}) / divisor;
52 return (dividend + divisor / T{2}) / divisor;
constexpr T IntegerDivisionRoundNearest(T dividend, T divisor)
Definition: integer_division.h:42
The Pigweed namespace.
Definition: alignment.h:27