]>
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 | .\" |
93015253 | 5 | .\" %%%LICENSE_START(VERBATIM) |
fea681da MK |
6 | .\" Permission is granted to make and distribute verbatim copies of this |
7 | .\" manual provided the copyright notice and this permission notice are | |
8 | .\" preserved on all copies. | |
9 | .\" | |
10 | .\" Permission is granted to copy and distribute modified versions of this | |
11 | .\" manual under the conditions for verbatim copying, provided that the | |
12 | .\" entire resulting derived work is distributed under the terms of a | |
13 | .\" permission notice identical to this one. | |
c13182ef | 14 | .\" |
fea681da MK |
15 | .\" Since the Linux kernel and libraries are constantly changing, this |
16 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
17 | .\" responsibility for errors or omissions, or for damages resulting from | |
18 | .\" the use of the information contained herein. The author(s) may not | |
19 | .\" have taken the same level of care in the production of this manual, | |
20 | .\" which is licensed free of charge, as they might when working | |
21 | .\" professionally. | |
c13182ef | 22 | .\" |
fea681da MK |
23 | .\" Formatted or processed versions of this manual, if unaccompanied by |
24 | .\" the source, must acknowledge the copyright and authors of this work. | |
4b72fb64 | 25 | .\" %%%LICENSE_END |
fea681da | 26 | .\" |
4b8c67d9 | 27 | .TH CEIL 3 2017-09-15 "" "Linux Programmer's Manual" |
fea681da | 28 | .SH NAME |
c13182ef | 29 | ceil, ceilf, ceill \- ceiling function: smallest integral value not |
35478399 | 30 | less than argument |
fea681da MK |
31 | .SH SYNOPSIS |
32 | .nf | |
33 | .B #include <math.h> | |
68e4db0a | 34 | .PP |
fea681da | 35 | .BI "double ceil(double " x ); |
fea681da | 36 | .BI "float ceilf(float " x ); |
fea681da MK |
37 | .BI "long double ceill(long double " x ); |
38 | .fi | |
68e4db0a | 39 | .PP |
20c58d70 | 40 | Link with \fI\-lm\fP. |
68e4db0a | 41 | .PP |
578d105f MK |
42 | .in -4n |
43 | Feature Test Macro Requirements for glibc (see | |
44 | .BR feature_test_macros (7)): | |
45 | .in | |
68e4db0a | 46 | .PP |
578d105f MK |
47 | .ad l |
48 | .BR ceilf (), | |
49 | .BR ceill (): | |
b90c43a8 | 50 | .RS 4 |
e9d91bcf MK |
51 | _ISOC99_SOURCE || _POSIX_C_SOURCE\ >=\ 200112L |
52 | || /* Since glibc 2.19: */ _DEFAULT_SOURCE | |
53 | || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE | |
b90c43a8 MK |
54 | .RE |
55 | .ad | |
fea681da | 56 | .SH DESCRIPTION |
578d105f MK |
57 | These functions return the smallest integral value that is not less than |
58 | .IR x . | |
847e0d88 | 59 | .PP |
578d105f MK |
60 | For example, |
61 | .IR ceil(0.5) | |
62 | is 1.0, and | |
63 | .IR ceil(\-0.5) | |
64 | is 0.0. | |
47297adb | 65 | .SH RETURN VALUE |
578d105f MK |
66 | These functions return the ceiling of |
67 | .IR x . | |
847e0d88 | 68 | .PP |
022671eb MK |
69 | If |
70 | .I x | |
71 | is integral, +0, \-0, NaN, or infinite, | |
72 | .I x | |
73 | itself is returned. | |
fea681da | 74 | .SH ERRORS |
578d105f | 75 | No errors occur. |
efe294cb | 76 | POSIX.1-2001 documents a range error for overflows, but see NOTES. |
ea32445b | 77 | .SH ATTRIBUTES |
9b6495b4 MK |
78 | For an explanation of the terms used in this section, see |
79 | .BR attributes (7). | |
80 | .TS | |
81 | allbox; | |
82 | lbw24 lb lb | |
83 | l l l. | |
84 | Interface Attribute Value | |
85 | T{ | |
ea32445b | 86 | .BR ceil (), |
ed21d749 | 87 | .BR ceilf (), |
ea32445b | 88 | .BR ceill () |
9b6495b4 MK |
89 | T} Thread safety MT-Safe |
90 | .TE | |
47297adb | 91 | .SH CONFORMING TO |
9a74e018 | 92 | C99, POSIX.1-2001, POSIX.1-2008. |
847e0d88 | 93 | .PP |
578d105f MK |
94 | The variant returning |
95 | .I double | |
96 | also conforms to | |
97 | SVr4, 4.3BSD, C89. | |
fea681da | 98 | .SH NOTES |
68e1685c | 99 | SUSv2 and POSIX.1-2001 contain text about overflow (which might set |
fea681da | 100 | .I errno |
a9b4ebbc MK |
101 | to |
102 | .BR ERANGE , | |
578d105f MK |
103 | or raise an |
104 | .B FE_OVERFLOW | |
105 | exception). | |
fea681da MK |
106 | In practice, the result cannot overflow on any current machine, |
107 | so this error-handling stuff is just nonsense. | |
578d105f | 108 | .\" The POSIX.1-2001 APPLICATION USAGE SECTION discusses this point. |
fea681da MK |
109 | (More precisely, overflow can happen only when the maximum value |
110 | of the exponent is smaller than the number of mantissa bits. | |
578d105f MK |
111 | For the IEEE-754 standard 32-bit and 64-bit floating-point numbers |
112 | the maximum value of the exponent is 128 (respectively, 1024), | |
113 | and the number of mantissa bits is 24 (respectively, 53).) | |
847e0d88 | 114 | .PP |
578d105f MK |
115 | The integral value returned by these functions may be too large |
116 | to store in an integer type | |
117 | .RI ( int , | |
118 | .IR long , | |
119 | etc.). | |
120 | To avoid an overflow, which will produce undefined results, | |
121 | an application should perform a range check on the returned value | |
122 | before assigning it to an integer type. | |
47297adb | 123 | .SH SEE ALSO |
fea681da MK |
124 | .BR floor (3), |
125 | .BR lrint (3), | |
126 | .BR nearbyint (3), | |
127 | .BR rint (3), | |
128 | .BR round (3), | |
129 | .BR trunc (3) |