]>
Commit | Line | Data |
---|---|---|
fea681da | 1 | .\" Copyright 2001 Andries Brouwer <aeb@cwi.nl>. |
578d105f MK |
2 | .\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk |
3 | .\" <mtk.manpages@gmail.com> | |
fea681da | 4 | .\" |
5fbde956 | 5 | .\" SPDX-License-Identifier: Linux-man-pages-copyleft |
fea681da | 6 | .\" |
1ae6b2c7 | 7 | .TH CEIL 3 2021-03-22 GNU "Linux Programmer's Manual" |
fea681da | 8 | .SH NAME |
c13182ef | 9 | ceil, ceilf, ceill \- ceiling function: smallest integral value not |
35478399 | 10 | less than argument |
2af19291 AC |
11 | .SH LIBRARY |
12 | Math library | |
8fc3b2cf | 13 | .RI ( libm ", " \-lm ) |
fea681da MK |
14 | .SH SYNOPSIS |
15 | .nf | |
16 | .B #include <math.h> | |
68e4db0a | 17 | .PP |
fea681da | 18 | .BI "double ceil(double " x ); |
fea681da | 19 | .BI "float ceilf(float " x ); |
fea681da MK |
20 | .BI "long double ceill(long double " x ); |
21 | .fi | |
68e4db0a | 22 | .PP |
d39ad78f | 23 | .RS -4 |
578d105f MK |
24 | Feature Test Macro Requirements for glibc (see |
25 | .BR feature_test_macros (7)): | |
d39ad78f | 26 | .RE |
68e4db0a | 27 | .PP |
578d105f MK |
28 | .BR ceilf (), |
29 | .BR ceill (): | |
9d2adbae | 30 | .nf |
5c10d2c5 | 31 | _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L |
9d2adbae MK |
32 | || /* Since glibc 2.19: */ _DEFAULT_SOURCE |
33 | || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE | |
34 | .fi | |
fea681da | 35 | .SH DESCRIPTION |
578d105f MK |
36 | These functions return the smallest integral value that is not less than |
37 | .IR x . | |
847e0d88 | 38 | .PP |
578d105f | 39 | For example, |
1ae6b2c7 | 40 | .I ceil(0.5) |
578d105f | 41 | is 1.0, and |
1ae6b2c7 | 42 | .I ceil(\-0.5) |
578d105f | 43 | is 0.0. |
47297adb | 44 | .SH RETURN VALUE |
578d105f MK |
45 | These functions return the ceiling of |
46 | .IR x . | |
847e0d88 | 47 | .PP |
022671eb MK |
48 | If |
49 | .I x | |
50 | is integral, +0, \-0, NaN, or infinite, | |
51 | .I x | |
52 | itself is returned. | |
fea681da | 53 | .SH ERRORS |
578d105f | 54 | No errors occur. |
efe294cb | 55 | POSIX.1-2001 documents a range error for overflows, but see NOTES. |
ea32445b | 56 | .SH ATTRIBUTES |
9b6495b4 MK |
57 | For an explanation of the terms used in this section, see |
58 | .BR attributes (7). | |
c466875e MK |
59 | .ad l |
60 | .nh | |
9b6495b4 MK |
61 | .TS |
62 | allbox; | |
c466875e | 63 | lbx lb lb |
9b6495b4 MK |
64 | l l l. |
65 | Interface Attribute Value | |
66 | T{ | |
ea32445b | 67 | .BR ceil (), |
ed21d749 | 68 | .BR ceilf (), |
ea32445b | 69 | .BR ceill () |
9b6495b4 MK |
70 | T} Thread safety MT-Safe |
71 | .TE | |
c466875e MK |
72 | .hy |
73 | .ad | |
74 | .sp 1 | |
47297adb | 75 | .SH CONFORMING TO |
9a74e018 | 76 | C99, POSIX.1-2001, POSIX.1-2008. |
847e0d88 | 77 | .PP |
578d105f MK |
78 | The variant returning |
79 | .I double | |
80 | also conforms to | |
81 | SVr4, 4.3BSD, C89. | |
fea681da | 82 | .SH NOTES |
68e1685c | 83 | SUSv2 and POSIX.1-2001 contain text about overflow (which might set |
fea681da | 84 | .I errno |
a9b4ebbc MK |
85 | to |
86 | .BR ERANGE , | |
578d105f MK |
87 | or raise an |
88 | .B FE_OVERFLOW | |
89 | exception). | |
fea681da MK |
90 | In practice, the result cannot overflow on any current machine, |
91 | so this error-handling stuff is just nonsense. | |
578d105f | 92 | .\" The POSIX.1-2001 APPLICATION USAGE SECTION discusses this point. |
fea681da MK |
93 | (More precisely, overflow can happen only when the maximum value |
94 | of the exponent is smaller than the number of mantissa bits. | |
578d105f MK |
95 | For the IEEE-754 standard 32-bit and 64-bit floating-point numbers |
96 | the maximum value of the exponent is 128 (respectively, 1024), | |
97 | and the number of mantissa bits is 24 (respectively, 53).) | |
847e0d88 | 98 | .PP |
578d105f MK |
99 | The integral value returned by these functions may be too large |
100 | to store in an integer type | |
101 | .RI ( int , | |
102 | .IR long , | |
103 | etc.). | |
104 | To avoid an overflow, which will produce undefined results, | |
105 | an application should perform a range check on the returned value | |
106 | before assigning it to an integer type. | |
47297adb | 107 | .SH SEE ALSO |
fea681da MK |
108 | .BR floor (3), |
109 | .BR lrint (3), | |
110 | .BR nearbyint (3), | |
111 | .BR rint (3), | |
112 | .BR round (3), | |
113 | .BR trunc (3) |