NAME

satsub - saturated subtraction

SYNOPSIS

val1.satsub(val2, min, max)

DESCRIPTION

The satsub() method performs saturated subtraction of val1 and val2 within the range [min, max]. The result is equivalent to (val1 - val2).clamp(min, max).

If any argument is an array, the operation is performed element-wise. All arguments must be numeric.

RETURN VALUE

The result of the saturated subtraction, clamped to the range [min, max].

ERRORS

TypeCheck if any argument is not numeric
ArgCheck if an incorrect number of arguments is given
RangeCheck if min is greater than max

EXAMPLE

    100->satsub(50, 0, 120)
50

    100->satsub(200, 0, 120)
0

    a = [70, 20, 30]
    a.satsub(50, 0, 70)
20 0 0

SEE ALSO

clamp
satadd