Date: Sat, 17 Feb 2024 14:47:40 +0100
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.
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.
Received on 2024-02-17 13:47:52