ceil(3)
โจ ceil(3) โ the ceiling function, bestie โจ
okay so this is from the Library Functions Manual, and we're talking about ceil, ceilf, and ceill โ the ceiling function: smallest integral value not less than argument. ๐
๐ NAME ๐
ceil, ceilf, ceill โ ceiling function: smallest integral value not less than argument ๐ฆ
๐ LIBRARY ๐
Math library (libm, link it with -lm) ๐ฅ
โจ SYNOPSIS โจ
#include <math.h>
double ceil(double x);
float ceilf(float x);
long double ceill(long double x);
๐ธ Feature Test Macro Requirements for glibc (see feature_test_macros(7)): ๐ธ
ceilf(), ceill():
_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
|| /* Since glibc 2.19: */ _DEFAULT_SOURCE
|| /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
likeโฆ yes you have to define the right macro first, it's giving โจbureaucracyโจ but we move ๐
๐ DESCRIPTION ๐
So these functions return the smallest integral value that is not less than x. That's literally the whole vibe. ๐ซถ
For example, ceil(0.5) is 1.0, and ceil(-0.5) is 0.0. no cap. ๐ญ
๐ฅ RETURN VALUE ๐ฅ
These functions return the ceiling of x. ๐
If x is integral, +0, -0, NaN, or infinite, x itself is returned. so it just hands you back your own little guy, unchanged. iconic. ๐
๐ ERRORS ๐
No errors occur. not one. zero. the girl is flawless. โจ
๐ ATTRIBUTES ๐
For an explanation of the terms used in this section, see attributes(7).
- Interface:
ceil(),ceilf(),ceill()- Attribute: Thread safety
- Value:
MT-Safeโ
(it was a table in the original, but tables are not it, so here's the tea in bullet form ๐)
๐ STANDARDS ๐
C11, POSIX.1-2008. periodt. ๐
๐ฆ HISTORY ๐ฆ
C99, POSIX.1-2001.
The variant returning double also conforms to SVr4, 4.3BSD, C89.
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).) This was removed in POSIX.1-2008.
๐จ okay so listen up bestie because this part is IMPORTANT ๐จ The integral value returned by these functions may be too large to store in an integer type (int,long, etc.). To avoid an overflow, which will produce undefined results, an application should perform a range check on the returned value before assigning it to an integer type.
so like. check before you cast. do not just yolo it into an int. that's how you get cursed undefined behaviour and nobody wants that energy. ๐
๐ SEE ALSO ๐
floor(3), lrint(3), nearbyint(3), rint(3), round(3), trunc(3) โ the whole rounding friend group, go say hi ๐ธ
and that's the page!! this one's from Linux man-pages 6.20, dated 2026-02-08, and it's the ceil(3) entry obviously ๐
thanks for reading bestie, go round your floats responsibly, mwah ๐๐โจ
๐ฆ 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