Ceiling function 2026-10-14
The ceiling function gives the least integer large enough to meet a real lower bound. For a real number ,Thus , , and . The operation rounds upward in the total order on the real numbers, which can move a negative input towards zero. Its difference from the input obeys . Python's
math.ceil implements this least-integer definition. [ref]https://docs.python.org/3.14/library/math.html#math.ceil. Python 3.14 math.ceil documentation: the least integer at least x
.The ceiling count for fixed-size batches is a direct application. Suppose each box holds at most items, with positive integer , and there are items. The smallest number of boxes with enough capacity is : a candidate count must satisfy . For , , six boxes are needed, leaving unused places. Exactly 100 items need only five boxes, and zero items need zero boxes. Adding one to the floor function result unconditionally would therefore overcount at exact multiples of .
The ceiling function retains the endpoint on the left and counts enough whole containers
. Left: open and filled endpoints distinguish the half-open intervals where , including negative inputs. Right: the original capacity example uses 20 items per box; 101 items need six boxes, while an exact multiple of 20 needs no extra box. The right-hand inputs are integer item counts. Details.For nonnegative integer and positive integer , Euclidean division gives the exact identityWrite , . The count is when the remainder is zero and otherwise, and the right-hand side encodes these two cases. This argument specifies the domain of the identity; arbitrary negative denominators require their own sign conventions.
The ceiling function is a nondecreasing function, constant on each of the half-open intervals , and has a discontinuity of a function at every integer. It is tied to the floor function by . Adding an integer shifts its output by the same amount: . At an integer the floor and ceiling agree; at every other input they differ by one. These statements refer to exact real numbers; an input already perturbed by floating-point arithmetic can land on the other side of a threshold.
Floor and ceiling functions 2026-10-14
The floor function and ceiling function turn a real number into directed integer bounds. They answer two different questions: which integer is the largest one that does not exceed , and which is the smallest one that is not less than ?Both outputs are integers. These are exact mathematical operations; they need not choose the closest integer, and they do not refer to roundoff error in floating-point arithmetic.
For example,The fractional part is . The negative example matters: discarding the digits after the decimal point would give , which is truncation toward zero, rather than the floor function's value . At an integer, the floor function and ceiling function agree and the fractional part vanishes.
The usefulness is a bridge from continuous quantities to discrete decisions. An integer count in a closed interval uses both bounds. A ceiling count for fixed-size batches counts how many containers or pages are needed; a floor function counts how many complete groups fit. In Euclidean division, the same bounds specify the quotient, while the fractional part records the scaled remainder. A small amount of notation removes many cases that would otherwise have to be stated separately.
The reflection identityfollows by reflecting the ordered integers across zero: the largest one below becomes the smallest one above . For every integer , translation gives and . These formulas turn upper bounds into lower bounds and move examples between neighboring intervals.
For a historical example of the notation in use, Kenneth E. Iverson's 1962 conference paper A Programming Language lists the floor function, ceiling function and residue operation alongside the ordinary arithmetic operations. It states the two defining inequalities above, then extends operations component by component to vectors and matrices. This shows their role as tools for describing algorithms, rather than merely conventions for writing decimal numbers. [ref]
https://www.jsoftware.com/papers/AFIPS196205a.htm. Iverson, A Programming Language, AFIPS Spring Joint Computer Conference, May 1962, Basic Operations; transcription with typography changes documented at the end
Integer arithmetic 2026-10-13
Integer arithmetic computes with integers. Addition, subtraction and multiplication preserve integer values; division can instead return a quotient and remainder through Euclidean division. For example, gives five complete groups and a remainder of two. The ceiling count for fixed-size batches requires six groups to hold all 102 items.
Mathematical integers have no fixed size bound. A computer representation may have one, so an exact arithmetic formula still requires sufficient space for its inputs and intermediate values. The floor function and ceiling function define mathematical bounds independently of a chosen representation.

