Skip to content

The Ceiling Function: Rounding Up

Textbook

The ceiling of a real number $x$, written $\lceil x\rceil$, is the least integer no smaller than $x$. If $k=\lceil x\rceil$, then $k-1<x\le k$. For integer $x$, the identity is $\lceil x\rceil=x$: rounding does not add one unnecessarily.

Thus $\lceil2.7\rceil=3$ and $\lceil-2.7\rceil=-2$. For positive integers $n,c$, storing $n$ records on pages of capacity $c$ takes $\lceil n/c\rceil$ pages. A partly filled last group still needs its own page. If division is exact, no extra page is required.

The defining inequality establishes minimality: $k$ is already at least $x$, but the previous integer $k-1$ is too small. Hence $0\le\lceil x\rceil-x<1$. For an integer input, rounding error is zero; otherwise it is positive. With negative numbers, moving upward still means choosing a larger number, so βˆ’2 qualifies for βˆ’2.7 even though its absolute value is smaller.

Definitions and further reading: Mathematics for Computer Science.

In plain language

The ceiling resembles the number of whole containers needed for belongings: a requirement of 2.75 containers needs three. An exact requirement of two needs no third, and an empty requirement needs none. The rule selects the nearest integer at or above the input without adding an automatic service surcharge. Containers model nonnegative quantities; for negative inputs, the number line determines the direction rather than the packaging returns desk.

Example

The example places the original 11 records on pages of capacity 4. Two pages hold eight; the remaining three need one more. The result 3 satisfies $2<11/4\le3$.

The Ceiling Function: Rounding Up

First page

Four records are placed; seven remain.

Step 1 of 3: First page

Read all steps
  1. First page

    Four records are placed; seven remain.

    State
    1–4included5–11current
  2. Second page

    Eight records are placed; three still need space.

    State
    1–4included5–8included9–11current
  3. Third page

    The partly filled last page brings the total to three.

    State
    1–4included5–8included9–11included

Three pages provide 12 spaces, leaving one unused. That spare space does not make the answer excessive: two pages provide only 8 spaces and fail the capacity requirement. This checks both sides of the definition, sufficiency of three and insufficiency of the previous integer. Exactly eight records would leave no partial group, so the same principle would require only two pages without an extra charge.

Related concepts: Floor, Remainders.

The original text of this free article is published under CC BY-NC-ND 4.0.

Previous / next

Previous
The Floor Function: Rounding Down
Next
Remainders: Reading a mod m
  • Natural Numbers: Counting Discrete Objects

    Which values count discrete objects, and why the zero convention must be stated.

    Read article
    Math
  • Integers: Counting on Both Sides of Zero

    Positive and negative integers, zero, and the limits of integer division.

    Read article
    Math
  • Rational Numbers: Ratios of Integers

    Numbers as ratios of integers: equivalent fractions and the nonzero denominator requirement.

    Read article
    Math