Integer count in a closed interval

ID: integer-count-in-a-closed-interval

For real numbers , the integers in the closed interval begin at and end at , if there are any. Their number is therefore
The extra one includes both ends of the resulting integer interval. The maximum with zero handles an empty intersection: contains no integer, even though it has positive length.
For , the ceiling function selects and the floor function selects , giving . The four points are . For , the count is five, not four: the real length and the number of integer points are different quantities.
The endpoint convention matters. For the half-open interval with , the last allowed integer is , so the count becomes . This handles an integer endpoint without including it accidentally. For example, has four integer points.

New to topics? Read the docs here!