Floor Function in LaTeX

The floor function is written with the delimiters \lfloor and \rfloor: \lfloor x \rfloor. The ceiling uses \lceil x \rceil. Both are built into LaTeX; add \left and \right when the contents are taller than one line of text.

Floor and ceiling commands

  • \lfloor x \rfloor
    ⌊ x ⌋

    Floor: the greatest integer ≤ x.

  • \lceil x \rceil
    ⌈ x ⌉

    Ceiling: the least integer ≥ x.

  • \left\lfloor \frac{a}{b} \right\rfloor
    ⌊ a b ⌋

    Floor brackets that grow with the contents.

  • \left\lceil \frac{a}{b} \right\rceil
    ⌈ a b ⌉

    Ceiling brackets that grow.

  • \bigl\lfloor x \bigr\rfloor
    ⌊ x ⌋

    Fixed larger size.

  • \lfloor x \rceil
    ⌊ x ⌉

    Mixed pair, sometimes used for rounding to the nearest integer.

  • \floor{x}
    Text mode, no math preview

    Your own macro after \DeclarePairedDelimiter\floor{\lfloor}{\rfloor} (mathtools).

Try it live

Change the formula and the preview redraws as you type. Copy the LaTeX, download a PNG or SVG, copy it for Word, or use Edit here on any example below to load it.

Templates

Floor and ceiling examples

Each result below is drawn from the LaTeX under it. Copy the code, edit it on this page, or open it in the full editor.

  • Floor and ceiling of a number

    ⌊ 3.7 ⌋ = 3 , ⌈ 3.2 ⌉ = 4
    LaTeX
    \lfloor 3.7 \rfloor = 3, \quad \lceil 3.2 \rceil = 4
  • Negative numbers

    ⌊ − 2.5 ⌋ = − 3 , ⌈ − 2.5 ⌉ = − 2
    LaTeX
    \lfloor -2.5 \rfloor = -3, \quad \lceil -2.5 \rceil = -2
  • Integer division

    q = ⌊ a b ⌋ , r = a − b q
    LaTeX
    q = \left\lfloor \frac{a}{b} \right\rfloor, \quad r = a - b q
  • Halves

    ⌊ n 2 ⌋ + ⌈ n 2 ⌉ = n
    LaTeX
    \left\lfloor \frac{n}{2} \right\rfloor + \left\lceil \frac{n}{2} \right\rceil = n
  • Number of digits

    d ( n ) = ⌊ log 10 ⁡ n ⌋ + 1
    LaTeX
    d(n) = \lfloor \log_{10} n \rfloor + 1
  • Fractional part

    { x } = x − ⌊ x ⌋
    LaTeX
    \{ x \} = x - \lfloor x \rfloor
  • Definition of the floor

    ⌊ x ⌋ = max { n ∈ Z : n ≤ x }
    LaTeX
    \lfloor x \rfloor = \max \{ n \in \mathbb{Z} : n \le x \}

How to write floor and ceiling

All four symbols are standard delimiters in LaTeX, so no package is needed: \lfloor, \rfloor, \lceil, \rceil. Because they are delimiters, they work with \left / \right and the \big family just like parentheses.

Use \left\lfloor … \right\rfloor around fractions and logarithms, otherwise the brackets stay text height and look cut off.

\floor and \ceil macros

LaTeX has no \floor or \ceil command out of the box, which is why copying \floor{x} from someone else’s notes can fail. Define them with mathtools; the starred form then stretches automatically.

LaTeX
\usepackage{mathtools}
\DeclarePairedDelimiter\floor{\lfloor}{\rfloor}
\DeclarePairedDelimiter\ceil{\lceil}{\rceil}
% ...
\[ \floor*{\frac{n}{2}} \le \ceil{x} \]

Common mistakes

  • \floor is not a built-in command; it only exists after you define it.

    Instead of
    \floor{x}  (no definition)
    Write
    \lfloor x \rfloor
  • Fixed-size brackets look too short next to a fraction.

    Instead of
    \lfloor \frac{n}{2} \rfloor
    Write
    \left\lfloor \frac{n}{2} \right\rfloor
  • Square brackets are an older notation that readers may take as ordinary grouping; the floor symbols are unambiguous.

    Instead of
    [x]  (for the floor)
    Write
    \lfloor x \rfloor

In Overleaf, MathJax and Word

  • Overleaf and pdfLaTeX

    \lfloor, \rfloor, \lceil and \rceil work without packages; \bigl / \bigr need amsmath and \DeclarePairedDelimiter needs mathtools.

  • MathJax and KaTeX

    MathJax and KaTeX render all four delimiters and their \left / \right forms. \floor and \ceil are not predefined, so define them as macros in the renderer’s configuration or write the delimiters out.

  • Microsoft Word

    Word has floor and ceiling brackets under Bracket, but pasted LaTeX is not converted reliably. Build the expression here and use Copy for Word to paste it as an editable equation.

Floor and ceiling in LaTeX: questions

What is the LaTeX code for the floor function?
\lfloor x \rfloor, in math mode. The ceiling is \lceil x \rceil.
How do I make floor brackets bigger?
Use \left\lfloor … \right\rfloor to fit the contents, or a fixed size such as \bigl\lfloor … \bigr\rfloor.
Why does \floor{x} give an error?
It is not a standard command. Either write \lfloor x \rfloor or define \floor with \DeclarePairedDelimiter from mathtools.
Is there a symbol for rounding to the nearest integer?
There is no single standard. Some authors use the mixed pair \lfloor x \rceil; others write \operatorname{round}(x). Define the notation where you first use it.

Have the formula as a picture?

Paste a screenshot or photo of the equation and get its LaTeX, ready to copy or open in the editor.

Convert an image to LaTeX