Saturation arithmetic
Type of arithmetic where output is limited to a fixed range of values / From Wikipedia, the free encyclopedia
Dear Wikiwand AI, let's keep it short by simply answering these key questions:
Can you list the top facts and stats about Saturation arithmetic?
Summarize this article for a 10 year old
Saturation arithmetic is a version of arithmetic in which all operations, such as addition and multiplication, are limited to a fixed range between a minimum and maximum value.
If the result of an operation is greater than the maximum, it is set ("clamped") to the maximum; if it is below the minimum, it is clamped to the minimum. The name comes from how the value becomes "saturated" once it reaches the extreme values; further additions to a maximum or subtractions from a minimum will not change the result.
For example, if the valid range of values is from −100 to 100, the following saturating arithmetic operations produce the following values:
- 60 + 30 → 90.
- 60 + 43 → 100. (not the expected 103.)
- (60 + 43) − (75 + 25) → 0. (not the expected 3.) (100 − 100 → 0.)
- 10 × 11 → 100. (not the expected 110.)
- 99 × 99 → 100. (not the expected 9801.)
- 30 × (5 − 1) → 100. (not the expected 120.) (30 × 4 → 100.)
- (30 × 5) − (30 × 1) → 70. (not the expected 120. not the previous 100.) (100 − 30 → 70.)
Here is another example for saturating subtraction when the valid range is from 0 to 100 instead:
- 30 - 60 → 0. (not the expected -30.)
As can be seen from these examples, familiar properties like associativity and distributivity may fail in saturation arithmetic.[lower-alpha 1] This makes it unpleasant to deal with in abstract mathematics, but it has an important role to play in digital hardware and algorithms where values have maximum and minimum representable ranges.