A binary quadratic residue code of prime length is a cyclic code
whose defining zeros are
for the nonzero quadratic
residues
modulo
, where
is a primitive
th root of unity over a suitable
extension of
(MacWilliams and Sloane 1977, Ch. 16). Using the nonresidues instead gives an
equivalent code. The code has dimension
, and its minimum Hamming
distance satisfies
. The binary Hamming
code of length 7 and Golay code of length 23 are
examples.
Van Lint and MacWilliams (1978) generalized this construction to lengths that are odd prime powers with
. The coordinates are indexed by
, and the defining transform uses its additive characters,
with zeros indexed by its nonzero squares. These generalized quadratic residue codes
have dimension
and
; they need not be cyclic for nonprime
. For square
, the minimum distance is exactly
.
Gaborit and Lebacque (2026, Theorem 3.1) give a deterministic algorithm correcting every error pattern of weight at most
in all these binary generalized quadratic residue codes, using operations in
. This is a uniform guarantee
from the square-root bound; for prime lengths it need not reach half the actual minimum
distance.