Arithmetic coding is a lossless compression method that represents a message by a binary prefix whose numerical range lies inside an interval
assigned to the message (Rissanen and Langdon 1979, Witten et al. 1987). Start
with . In a fixed symbol order, partition the current
interval into consecutive half-open subintervals whose
lengths are proportional to the conditional
probabilities of the next symbols given the message so far. Retain the subinterval
for the actual symbol and repeat. The final interval
has length
, the product of those conditional probabilities.
A prefix of bits representing the integer
specifies the interval
of numbers having that
binary expansion prefix, using the terminating
expansion at dyadic endpoints. For any message with
, an interval of this form fits inside
when
, where
is the ceiling function.
Indeed, the mesh
is at most
, so rounding the left endpoint of
up to the next mesh point leaves room for a full mesh interval.
This gives a description of fewer than
bits.
With the same probability model, the decoder can use the left endpoint of the transmitted prefix interval to identify the chosen subinterval at each step. It stops after a known number of symbols or when it decodes a designated end symbol included in the model. 3Blue1Brown (2026) illustrates the successive subdivisions.