Floor in LaTeX (\lfloor x \rfloor)
- LaTeX command
\lfloor x \rfloor- Package
- No package needed: built into LaTeX
- Mode
- Math mode only
Where it is used
Rounds x down to the greatest integer less than or equal to it: the floor function.
The floor appears in integer division, in the fractional part \{x\} = x - \lfloor x \rfloor, in the binary search midpoint \lfloor (lo + hi)/2 \rfloor, and in number theory sums like Legendre's formula. For negative numbers it rounds away from zero: \lfloor -2.5 \rfloor = -3, which differs from truncation. Older literature wrote [x] for the floor (the Gauss bracket), but the bracket notation is now preferred because it is unambiguous. Use \left\lfloor ... \right\rfloor around fractions so the brackets match the content height.
Also listed under: Number Theory, Computer Science
Minimal compilable example
Paste this into an empty .tex file and compile it with pdfLaTeX, XeLaTeX or LuaLaTeX.
\documentclass{article}
\begin{document}
Floor: $\lfloor x \rfloor$
\[ x - 1 < \lfloor x \rfloor \le x \]
\end{document}Related symbols
- Double Vertical Bar
\| - Floor Right
\rfloor - Norm
\| x \| - Floor Left
\lfloor - Double Bracket Left
\llbracket - Ceiling
\lceil x \rceil
Frequently asked questions
- How do I write Floor in LaTeX?
- Type \lfloor x \rfloor in math mode, for example $x - 1 < \lfloor x \rfloor \le x$. It works in plain LaTeX without loading any package.
- Which package do I need for \lfloor x \rfloor?
- None. \lfloor x \rfloor is part of standard LaTeX, so it compiles with nothing in the preamble but the document class.
- Can I use \lfloor x \rfloor in text mode, or only in math mode?
- Only in math mode. Outside $...$ LaTeX stops with "Missing $ inserted", so write $\lfloor x \rfloor$ in running text.
Best AI LaTeX Editor, Overleaf Alternative
Octree helps researchers from 15+ universities write research papers faster using AI
- Generate beautiful TikZ diagrams using AI
- Upload image and convert it to LaTeX seamlessly
- Get instant assistance with writing and formatting research papers