Skip to content

function satsub(const T1 &, const T2 &) saturation

template <numeric T1, numeric T2, typename Tout = std::common_type_t<T1, T2>>
KFR_INTRINSIC Tout satsub(const T1& x, const T2& y)

Subtracts two numeric values using saturation arithmetic.

Saturated subtraction clamps the result to the maximum or minimum value representable by the result type if overflow or underflow occurs.

Template parameters
T1 Type of the first operand.
T2 Type of the second operand.
Tout Common type deduced from T1 and T2 (result type).
Parameters
x The first operand.
y The second operand.
Returns
The saturated difference of x and y.

Defined at simd/saturation.hpp:68