bsa

Source ยป Extra details

A library for branch-free saturating arithmetic. Provides addition, subtraction, division, and multiplication of 32 and 64-bit signed and unsigned integers. "Saturate" meaning the values cannot underflow or overflow (instead are limited by their _MIN and _MAX values respectively).

Signed and unsigned multiplication of 64-bit integers requires use of GNU extensions for __int128_t and __uint128_t.

Uses explicit casting wherever possible. Possibly-negative left operand bitwise right shifting is implementation-defined (but not undefined behavior).