A function is said to be piecewise constant if it is locally constant in connected regions separated by a possibly infinite number of lower-dimensional boundaries. The Heaviside step function, rectangle function, and square wave are examples of one-dimensional piecewise constant functions. Examples in two dimensions include and
(illustrated above) for
a complex number,
the real part, and
the floor function. The nearest integer function is also piecewise constant.