Floors and ceilings

Floors and ceilings


The floor and ceiling of a real number are integers, the result of rounding the real number down or up (respectively). When viewed as functions from \mathbb{R} to itself (or to \mathbb{Z}), these are standard examples of functions exhibiting partial notions of continuity: the floor function is both right-continuous? and upper semicontinuous, while the ceiling function is both left-continuous? and lower semicontinuous. They are step functions used to approximate definite integrals of continuous maps and otherwise to relate integrals and series. They provide convenient notation to express various notions of rounding?. From the perspective of order theory, the maps may be seen as the right adjoint and left adjoint (respectively) of the inclusion map from \mathbb{Z} to \mathbb{R}.


Given a real number xx, the floor of xx, denoted x\lfloor{x}\rfloor or [x][x], is the largest integer nn such that nxn \leq x, and the ceiling of xx, denoted x\lceil{x}\rceil, is the smallest integer nn such that nxn \geq x.

Typically the notation x\lfloor{x}\rfloor is used when both floor and ceiling appear, but [x][x] is often easier when only the floor is considered. Since

x=x, \lceil{x}\rceil = -\lfloor{-x}\rfloor ,

this is not actually a restriction.

The floor of xx is also called the integer part of xx, and then one refers as well to the fractional part of xx, denoted {x}\{x\}, defined by

{x}=x[x]. \{x\} = x - [x] .

One must of course prove that the floor of xx exists; this fails in constructive mathematics, although the floor of xx exists for almost all xx, and all of these functions can still be defined as continuous maps between appropriate locales.


As adjoint functors

We discuss how the floor and celing functions are left and right adjoint functors to the inclusion of the integers into the real numbers, if both are regarded as posets, and hence as categories.


(preordered sets as thin categories)

Let (S,)(S, \leq) be a preordered set. Then this induces a small category whose set of objects is SS, and which has precisely one morphism xyx \to y whenever xyx \leq y, and no such morphism otherwise:

(1)x!yAAAprecisely ifAAAxy x \overset{\exists !}{\to} y \phantom{AAA} \text{precisely if} \phantom{AAA} x \leq y

Conversely, every small category with at most one morphism from any object to any other, called a thin category, induces on its set of objects the structure of a partially ordered set via (1).

Here the axioms for preordered sets and for categories match as follows:

A\phantom{A}partially ordered setsA\phantom{A}A\phantom{A} xxx \leq x A\phantom{A}A\phantom{A} (xyz)(xz)(x \leq y \leq z) \Rightarrow (x \leq z) A\phantom{A}
A\phantom{A}thin categoriesA\phantom{A}A\phantom{A}identity morphismsA\phantom{A}A\phantom{A}compositionA\phantom{A}

(floor and ceiling as adjoint functors)

Consider the canonical inclusion

AAιAA \mathbb{Z}_{\leq} \overset{\phantom{AA}\iota \phantom{AA}}{\hookrightarrow} \mathbb{R}_{\leq}

of the integers into the real numbers, both regarded as preorders in the standard way (“lower or equal”). Regarded as full subcategory-inclusion of the corresponding thin categories, via Example , this inclusion functor has both a left and right adjoint functor:

(2)()ι(). \lceil(-)\rceil \;\;\dashv\;\; \iota \;\;\dashv\;\; \lfloor (-) \rfloor \,.

Hence this induces an adjoint modality, as discussed there.

The adjunction unit and adjunction counit express that each real number is in between its floor and ceiling

ιxxιx \iota \lfloor x \rfloor \;\leq\; x \;\leq\; \iota \lceil x \rceil

Hence the modal objects in both cases are the integers among the real numbers, while every real number is ceiling-submodal and floor-supmodal.


First of all, observe that we indeed have functors

(),(): \lfloor(-)\rfloor \;,\; \lceil(-)\rceil \;\;\colon\; \mathbb{R} \longrightarrow \mathbb{Z}

since floor and ceiling preserve the ordering relation.

Now in view of the identification of preorders with thin categories in Example , the hom-isomorphism defining adjoint functors of the form ι()\iota \dashv \lfloor(-)\rfloor says for all nn \in \mathbb{Z} and xx \in \mathbb{R}, that we have

nxnx. \underset{ \in \mathbb{Z}}{\underbrace{n \leq \lfloor x \rfloor}} \;\Leftrightarrow\; \underset{ \in \mathbb{R}}{\underbrace{n \leq x }} \,.

This is clearly already the defining condition on the floor function x\lfloor x \rfloor.

Similarly, the hom-isomorphism defining adjoint functors of the form ()ι\lceil(-)\rceil \dashv \iota says that for all nn \in \mathbb{Z} and xx \in \mathbb{R}, we have

xnxn. \underset{ \in \mathbb{Z}}{\underbrace{\lceil x \rceil \leq n}} \;\Leftrightarrow\; \underset{ \in \mathbb{R}}{\underbrace{x \leq n }} \,.

This is evidently already the defining condition on the floor function x\lfloor x \rfloor.

Notice that in both cases the condition of a natural isomorphism in both variables, as required for an adjunction, is automatically satisfied: For let xxx \leq x' and nnn' \leq n, then naturality means, again in view of the identifications in Example , that

(nx) (nx) (nx) (nx) \array{ (n \leq \lfloor x \rfloor) &\Leftrightarrow& (n \leq x) \\ \Downarrow && \Downarrow \\ (n' \leq \lfloor x' \rfloor) &\Leftrightarrow& (n' \leq x') \\ \\ \in \mathbb{Z} && \in \mathbb{R} }

where the logical implications are equivalently functions between sets that are either empty or singletons. But Functions between such sets are unique, when they exist.


Wikipedia summarizes the basic properties:

  • English Wikipedia. Floor and ceiling functions. Web.

Chapter 6 of these notes uses the floor and ceiling functions throughout to relate integrals and series when teaching infinitesimal calculus:

  • Toby Bartels. One-variable Calculus. Web.

Last revised on August 29, 2018 at 00:05:13. See the history of this page for a list of all contributions to it.