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