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
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms