SATURATING ADD when it overflows, stick at the top — do not wrap around to the bottom
Wrapping is a disaster for a signal: brighten a nearly-white pixel and it must not roll to black; push a loud sample past the max and it must not flip to silence. Saturating arithmetic forbids the wrap — when a result would overflow, it clamps to the maximum (or minimum) instead: 200+100 is 255, not 44. The carry, instead of rolling over, pins the value at the ceiling. It is the arithmetic of audio, graphics, and DSP, where a value is a physical quantity and going over should mean “as much as possible,” never “none.” The carry, caught and held at the edge.
THE TECHNIQUE on overflow, clamp to max/min instead of wrapping
The demo adds 200+100 with saturation — it clamps to 255 rather than wrapping to 44: live demo
HISTORY & CREDIT DSP / media arithmetic
“Overflow wraps.” — not for a signal: saturating arithmetic clamps to the ceiling, because a bright pixel must not become black. The carry pins instead of rolls. cited
saturate · result too big → the max; too small → the min. No wrap. where · audio samples, pixel channels, DSP (MMX/SSE/NEON have saturating adds). vs wrap · modular arithmetic wraps (dart 381); media arithmetic clamps.
Over the top means stay at the top, never fall to the bottom — the carry pinned at the edge. The arithmetic of things that are quantities. saturating add
RECOMMEND FOR I-13 the clamp, on the compiler
On the canonical compiler, saturating 200+100 gives 255 (clamped), not 44 (wrapped):
$ i13 run c_saturatingadd.i13 # raw 300 -> clamp to 255
RUN OK · 12 step(s) · peak stack 2 · call depth 0
raw = 300 clamp = 1
result = 255 -- pinned at the ceiling, not wrapped to 44
Recommend: the saturating add is the carry held at the edge — clamp, do not wrap, because a signal is a quantity — and i13 pins 200+100 to 255. Not a keeper (choosing clamp over wrap is an overflow policy, not a structural supplement; and “clamp” is the idempotent projection of dart 366). The dart that shows the carry's overflow has two honest answers — wrap or pin — and media chose pin.