What is Saturating arithmetic?

Arithmetic that clamps results exceeding the representable range to the maximum or minimum instead of wrapping around. Used in audio and image signal processing to avoid large errors.

Field: Computer Arithmetic

Japanese name: 飽和演算

Difference from wraparound

In ordinary integer arithmetic, a result beyond the range wraps around to the opposite end. An 8-bit signed integer can represent −128 to 127. Adding 100 and 100 really gives 200, but with wraparound the result is −56. With saturating arithmetic it stays at the upper limit, 127. For unsigned 8 bits (0 to 255), adding 100 to 200 gives 44 with wraparound and 255 with saturation. Subtracting 100 from 50 gives 206 with wraparound and 0 with saturation.

Why signal processing uses it

When an audio waveform slightly exceeds the maximum value and wraps around, the value jumps from near the positive maximum to near the negative maximum. This is heard as loud noise. With saturating arithmetic the top of the waveform is merely flattened and the error stays small. The same holds for images. When brightness is added and exceeds the upper limit, wraparound makes white areas suddenly dark, while saturation keeps them white.

Implementation and a caution

Digital signal processors (DSPs) and SIMD instructions, which process several data items at once, have saturating add and subtract instructions. As a circuit, it only detects overflow and replaces the result with the maximum or minimum value. Ordinary integer arithmetic in C does not saturate, so the programmer writes range checks or uses dedicated functions. One caution is that the result depends on the order of operations. In 8-bit signed arithmetic, evaluating 100 + 100 − 100 from the left gives 127 − 100, which is 27. Evaluating the last two first gives 100 + 0, which is 100.

Try it: questions about Saturating arithmetic

Which describes saturating arithmetic used in signal processing?

  1. AWhen a result exceeds the maximum, it is held at the maximum instead of wrapping around
  2. BWhen a result exceeds the maximum, the bit width grows automatically to keep the exact value
  3. CWhen a result exceeds the maximum, it is reset to 0 and recomputed
Show answer and explanation

Answer: A. When a result exceeds the maximum, it is held at the maximum instead of wrapping around

Ordinary integer arithmetic wraps around on overflow; in 8-bit signed arithmetic, 127 + 1 becomes −128. In audio or images that causes large errors, such as the brightest pixel suddenly turning dark. Saturating arithmetic clamps results above the maximum to the maximum (127) and below the minimum to the minimum (−128), keeping errors small. DSP and SIMD instruction sets provide it. The bit width does not grow, and results are not reset to 0.

FAQ

Can a program tell afterwards that saturation occurred?

On many processors, yes. When saturation occurs a dedicated flag is set and stays set until software clears it.

What happens in floating-point arithmetic?

A result beyond the representable range becomes infinity. It does not wrap around, so the sign-reversal errors of integer wraparound do not occur.

Questions that mention Saturating arithmetic (2)

Saturating arithmetic appears in 3 practice questions across 3 topics, including Computer Arithmetic, Digital Signal Processing Basics, Control Engineering Basics.

  1. In an FIR filter computation, products of 16-bit fixed-point data and coefficients are represented in 32 bits, and 256 of these products are added up. Which of the following is the minimum accumulator width that guarantees no overflow during the computation?
  2. Positional PI control is implemented on a microcontroller, with the duty cycle of a PWM signal (0 to 100%) as the manipulated variable. Which of the following is a correct countermeasure against integral windup?

Books on Computer Arithmetic Ad

As an Amazon Associate I earn from qualifying purchases.

Comparisons that include this term

Semiconductor, Electronics and Computing Calculators

This page was drafted with AI and fact-checked by a separate AI review before publication. Our Editorial policy explains how we write and check content. If you spot an error, please tell us on our Contact page.

Back to the glossary