Home

endexclusive

End-exclusive, also known as a half-open interval, is a convention for representing ranges in which the lower bound is included but the upper bound is not. Formally, a range is written as [start, end), meaning it contains all values x with start <= x < end. This concept is widely used in mathematics and computer science, especially in programming, data processing, and indexing schemes.

In programming, end-exclusive ranges are common for loops, slices, and subarray operations. For example, in Python,

Advantages of end-exclusive ranges include simpler boundary handling, easier computation of length, and convenient concatenation of

Variants and related concepts include open intervals (a, b) which exclude both ends, and closed intervals [a,

See also: half-open interval, open interval, closed interval, range, slicing.

range(start,
end)
yields
start
through
end-1,
demonstrating
the
end-exclusive
property.
Similarly,
many
languages
implement
slicing
operations
where
a[a:b]
includes
indices
from
a
up
to,
but
not
including,
b.
This
convention
aligns
well
with
zero-based
indexing
and
makes
length
calculations
straightforward:
the
number
of
elements
in
[start,
end)
is
end
-
start.
adjacent
ranges.
If
two
ranges
end-exclusive
[a,
b)
and
[b,
c)
are
combined,
they
form
[a,
c)
without
overlap
or
gaps.
It
also
reduces
off-by-one
errors
in
loops
and
array
operations.
b]
which
include
both
ends.
In
practice,
end-exclusive
ranges
are
a
standard
tool
for
representing
finite
intervals
in
algorithms,
data
processing,
and
software
libraries.