On Sat, 17 Feb 2024 at 13:49, Jan Schultke via Std-Proposals <std-proposals@lists.isocpp.org> wrote:

Please add a rem_wide function to your proposal.

Double-wide remainders are important for safe modular arithmetic. For

example, std::linear_congruential_generator is commonly implemented

using double-wide arithmetic through __int128. However, it would be

desirable to have a general solution for any integer type.

Your div_wide function does not cover this use case because it has the

precondition is_div_wide_defined. A rem_wide function would have a

wider contract. Only division by zero and the edge case of HUGE / -1

are problematic, but the remainder always fits into a 64-bit number.

FWIW, for std::linear_congruential_generator the integers involved are unsigned and the remainder is a compile-time constant that can't be zero, so neither of those cases is a problem. That doesn't mean it couldn't be useful in other situations, but isn't needed for std::linear_congruential_generator.