On 5/1/20 2:09 AM, Bruno Haible wrote:
> I'm open to this. What prefix would you propose instead of 'x'?

The usual English-language name for this sort of thing is "saturation
arithmetic", but SATURATED_ADD is kind of long. LLVM uses "sat" for saturated
operations, perhaps the prefix "SAT" will do.

I could probably find uses for a new intprops.h macro INT_ADD_SAT (a, b) macro
that would behave like INT_ADD_WRAPV (a, b, r) except it would return a
saturated result instead of storing a wraparound-on-overflow result into *R and
returning an overflow indicator. This would be more general than a size_t-only
approach. It would be a little tricky, though, since A and B might not be the
same type and then how does one define saturation? would it be relative to the
type of A+B?

Reply via email to