1ceil(3) Library Functions Manual ceil(3)
2
3
4
6 ceil, ceilf, ceill - ceiling function: smallest integral value not less
7 than argument
8
10 Math library (libm, -lm)
11
13 #include <math.h>
14
15 double ceil(double x);
16 float ceilf(float x);
17 long double ceill(long double x);
18
19 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
20
21 ceilf(), ceill():
22 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
23 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
24 || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
25
27 These functions return the smallest integral value that is not less
28 than x.
29
30 For example, ceil(0.5) is 1.0, and ceil(-0.5) is 0.0.
31
33 These functions return the ceiling of x.
34
35 If x is integral, +0, -0, NaN, or infinite, x itself is returned.
36
38 No errors occur. POSIX.1-2001 documents a range error for overflows,
39 but see NOTES.
40
42 For an explanation of the terms used in this section, see at‐
43 tributes(7).
44
45 ┌────────────────────────────────────────────┬───────────────┬─────────┐
46 │Interface │ Attribute │ Value │
47 ├────────────────────────────────────────────┼───────────────┼─────────┤
48 │ceil(), ceilf(), ceill() │ Thread safety │ MT-Safe │
49 └────────────────────────────────────────────┴───────────────┴─────────┘
50
52 C11, POSIX.1-2008.
53
55 C99, POSIX.1-2001.
56
57 The variant returning double also conforms to SVr4, 4.3BSD, C89.
58
60 SUSv2 and POSIX.1-2001 contain text about overflow (which might set er‐
61 rno to ERANGE, or raise an FE_OVERFLOW exception). In practice, the
62 result cannot overflow on any current machine, so this error-handling
63 stuff is just nonsense. (More precisely, overflow can happen only when
64 the maximum value of the exponent is smaller than the number of mantis‐
65 sa bits. For the IEEE-754 standard 32-bit and 64-bit floating-point
66 numbers the maximum value of the exponent is 127 (respectively, 1023),
67 and the number of mantissa bits including the implicit bit is 24 (re‐
68 spectively, 53).)
69
70 The integral value returned by these functions may be too large to
71 store in an integer type (int, long, etc.). To avoid an overflow,
72 which will produce undefined results, an application should perform a
73 range check on the returned value before assigning it to an integer
74 type.
75
77 floor(3), lrint(3), nearbyint(3), rint(3), round(3), trunc(3)
78
79
80
81Linux man-pages 6.04 2023-03-30 ceil(3)