floor(3)
โจ floor โ ok bestie let's talk about rounding DOWN โจ
Hiii so this is the manual page for floor and its lil siblings floorf and floorl, from the math library gang ๐ The name situation, per the page itself: floor, floorf, floorl โ largest integral value not greater than argument. Slay. That's the whole personality.
๐ LIBRARY
Math library (libm, link it with -lm) ๐งฎโจ
If you forget the -lm, the linker will simply not know her. Tragic. Don't do that.
๐ซถ SYNOPSIS
#include <math.h>
double floor(double x);
float floorf(float x);
long double floorl(long double x);
๐ธ Feature Test Macro Requirements for glibc (go read feature_test_macros(7) if you want the lore)
For floorf(), floorl():
_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
|| /* Since glibc 2.19: */ _DEFAULT_SOURCE
|| /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
Like yes, macro gatekeeping, we've all been there ๐ Just copy it exactly, bestie.
๐ DESCRIPTION
Okay so these functions return the largest integral value that is not greater than x. That's the entire job. She does one thing and she does it flawlessly, honestly main character energy ๐
For example, floor(0.5) is 0.0, and floor(-0.5) is -1.0.
Not me reminding you that it goes toward negative infinity, not toward zero ๐ญ numbers below zero get spicier, that's just how it is.
๐ RETURN VALUE
These functions return the floor of x. That's it, that's the return value, she said what she said โจ
If x is integral, +0, -0, NaN, or an infinity, then x itself is returned. Like, no notes, unchanged, untouched, queen behavior ๐
๐ ERRORS
No errors occur.
Genuinely. None. She is unbothered, moisturized, in her lane, and error-free ๐โจ
๐ฅ ATTRIBUTES
For an explanation of the terms used in this section, go peek at attributes(7) ๐
floor(),floorf(),floorl()โ Thread safety:MT-Safe๐ซถ
MT-Safe means you can call her from multiple threads and she will not start drama. Iconic.
๐ STANDARDS
C11, POSIX.1-2008.
๐ฆ HISTORY
C99, POSIX.1-2001.
The variant returning double also conforms to SVr4, 4.3BSD, C89. So she's got range, she's been around, she's a legacy legend ๐
Now โ SUSv2 and POSIX.1-2001 contain text about overflow (which might set errno to ERANGE, or raise an FE_OVERFLOW exception). In practice, the result cannot overflow on any current machine, so this error-handling stuff was just nonsense. ๐
More precisely, overflow can happen only when the maximum value of the exponent is smaller than the number of mantissa bits. For the IEEE-754 standard 32-bit and 64-bit floating-point numbers the maximum value of the exponent is 127 (respectively, 1023), and the number of mantissa bits including the implicit bit is 24 (respectively, 53). So like. Literally cannot happen. ๐
This was removed in POSIX.1-2008. Good riddance bestie, we do not miss the nonsense โจ
๐ SEE ALSO
The whole rounding friend group ๐ธ go say hi.
Okay that's the whole page, you're officially fluent in floor ๐
This was Linux man-pages 6.20, dated 2026-02-08, and yes she's still serving floor(3) exactly like this. Go forth and round down responsibly, bestie ๐ซถโจ๐
๐ฆ where this page comes from
- arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- ๐ the page's license: Linux-man-pages-copyleft
- Copyright 2001, Andries E. Brouwer <aeb@cwi.nl>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms