<s>
Saturation	B-Algorithm
arithmetic	I-Algorithm
is	O
a	O
version	O
of	O
arithmetic	O
in	O
which	O
all	O
operations	O
,	O
such	O
as	O
addition	O
and	O
multiplication	O
,	O
are	O
limited	O
to	O
a	O
fixed	O
range	O
between	O
a	O
minimum	O
and	O
maximum	O
value	O
.	O
</s>
<s>
If	O
the	O
result	O
of	O
an	O
operation	O
is	O
greater	O
than	O
the	O
maximum	O
,	O
it	O
is	O
set	O
(	O
"	O
clamped	B-Algorithm
"	O
)	O
to	O
the	O
maximum	O
;	O
if	O
it	O
is	O
below	O
the	O
minimum	O
,	O
it	O
is	O
clamped	B-Algorithm
to	O
the	O
minimum	O
.	O
</s>
<s>
For	O
example	O
,	O
if	O
the	O
valid	O
range	O
of	O
values	O
is	O
from	O
−100	O
to	O
100	O
,	O
the	O
following	O
saturating	B-Algorithm
arithmetic	I-Algorithm
operations	O
produce	O
the	O
following	O
values	O
:	O
</s>
<s>
As	O
can	O
be	O
seen	O
from	O
these	O
examples	O
,	O
familiar	O
properties	O
like	O
associativity	O
and	O
distributivity	O
may	O
fail	O
in	O
saturation	B-Algorithm
arithmetic	I-Algorithm
.	O
</s>
<s>
Typically	O
,	O
general-purpose	O
microprocessors	B-Architecture
do	O
not	O
implement	O
integer	O
arithmetic	O
operations	O
using	O
saturation	B-Algorithm
arithmetic	I-Algorithm
;	O
instead	O
,	O
they	O
use	O
the	O
easier-to-implement	O
modular	O
arithmetic	O
,	O
in	O
which	O
values	O
exceeding	O
the	O
maximum	O
value	O
"	O
wrap	B-Error_Name
around	I-Error_Name
"	O
to	O
the	O
minimum	O
value	O
,	O
like	O
the	O
hours	O
on	O
a	O
clock	O
passing	O
from	O
12	O
to	O
1	O
.	O
</s>
<s>
However	O
,	O
although	O
more	O
difficult	O
to	O
implement	O
,	O
saturation	B-Algorithm
arithmetic	I-Algorithm
has	O
numerous	O
practical	O
advantages	O
.	O
</s>
<s>
The	O
result	O
is	O
as	O
numerically	O
close	O
to	O
the	O
true	O
answer	O
as	O
possible	O
;	O
for	O
8-bit	O
binary	O
signed	O
arithmetic	O
,	O
when	O
the	O
correct	O
answer	O
is	O
130	O
,	O
it	O
is	O
considerably	O
less	O
surprising	O
to	O
get	O
an	O
answer	O
of	O
127	O
from	O
saturating	B-Algorithm
arithmetic	I-Algorithm
than	O
to	O
get	O
an	O
answer	O
of	O
−126	O
from	O
modular	O
arithmetic	O
.	O
</s>
<s>
Likewise	O
,	O
for	O
8-bit	O
binary	O
unsigned	O
arithmetic	O
,	O
when	O
the	O
correct	O
answer	O
is	O
258	O
,	O
it	O
is	O
less	O
surprising	O
to	O
get	O
an	O
answer	O
of	O
255	O
from	O
saturating	B-Algorithm
arithmetic	I-Algorithm
than	O
to	O
get	O
an	O
answer	O
of	O
2	O
from	O
modular	O
arithmetic	O
.	O
</s>
<s>
Saturation	B-Algorithm
arithmetic	I-Algorithm
also	O
enables	O
overflow	O
of	O
additions	O
and	O
multiplications	O
to	O
be	O
detected	O
consistently	O
without	O
an	O
overflow	O
bit	O
or	O
excessive	O
computation	O
,	O
by	O
simple	O
comparison	O
with	O
the	O
maximum	O
or	O
minimum	O
value	O
(	O
provided	O
the	O
datum	O
is	O
not	O
permitted	O
to	O
take	O
on	O
these	O
values	O
)	O
.	O
</s>
<s>
Additionally	O
,	O
saturation	B-Algorithm
arithmetic	I-Algorithm
enables	O
efficient	O
algorithms	O
for	O
many	O
problems	O
,	O
particularly	O
in	O
digital	B-General_Concept
signal	I-General_Concept
processing	I-General_Concept
.	O
</s>
<s>
Saturation	B-Algorithm
arithmetic	I-Algorithm
operations	O
are	O
available	O
on	O
many	O
modern	O
platforms	O
,	O
and	O
in	O
particular	O
was	O
one	O
of	O
the	O
extensions	O
made	O
by	O
the	O
Intel	O
MMX	B-Architecture
platform	O
,	O
specifically	O
for	O
such	O
signal-processing	O
applications	O
.	O
</s>
<s>
This	O
functionality	O
is	O
also	O
available	O
in	O
wider	O
versions	O
in	O
the	O
SSE2	B-General_Concept
and	O
AVX2	O
integer	O
instruction	O
sets	O
.	O
</s>
<s>
Saturation	B-Algorithm
arithmetic	I-Algorithm
for	O
integers	O
has	O
also	O
been	O
implemented	O
in	O
software	O
for	O
a	O
number	O
of	O
programming	O
languages	O
including	O
C	B-Language
,	O
C++	B-Language
,	O
such	O
as	O
the	O
GNU	B-Application
Compiler	I-Application
Collection	I-Application
,	O
LLVM	B-Application
IR	O
,	O
and	O
Eiffel	B-Language
.	O
</s>
<s>
However	O
,	O
it	O
is	O
possible	O
to	O
implement	O
saturating	B-Algorithm
addition	I-Algorithm
and	O
subtraction	O
in	O
software	O
without	O
branches	O
,	O
using	O
only	O
modular	O
arithmetic	O
and	O
bitwise	O
logical	O
operations	O
that	O
are	O
available	O
on	O
all	O
modern	O
CPUs	O
and	O
their	O
predecessors	O
,	O
including	O
all	O
x86	O
CPUs	O
(	O
back	O
to	O
the	O
original	O
Intel	B-General_Concept
8086	I-General_Concept
)	O
and	O
some	O
popular	O
8-bit	O
CPUs	O
(	O
some	O
of	O
which	O
,	O
such	O
as	O
the	O
Zilog	B-General_Concept
Z80	I-General_Concept
,	O
are	O
still	O
in	O
production	O
)	O
.	O
</s>
<s>
On	O
the	O
x86	O
,	O
which	O
provides	O
overflow	O
flags	O
and	O
conditional	B-General_Concept
moves	I-General_Concept
,	O
very	O
simple	O
branch-free	O
code	O
is	O
possible	O
.	O
</s>
<s>
Although	O
saturation	B-Algorithm
arithmetic	I-Algorithm
is	O
less	O
popular	O
for	O
integer	O
arithmetic	O
in	O
hardware	O
,	O
the	O
IEEE	O
floating-point	O
standard	O
,	O
the	O
most	O
popular	O
abstraction	O
for	O
dealing	O
with	O
approximate	O
real	O
numbers	O
,	O
uses	O
a	O
form	O
of	O
saturation	O
in	O
which	O
overflow	O
is	O
converted	O
into	O
"	O
infinity	O
"	O
or	O
"	O
negative	O
infinity	O
"	O
,	O
and	O
any	O
other	O
operation	O
on	O
this	O
result	O
continues	O
to	O
produce	O
the	O
same	O
value	O
.	O
</s>
