]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/ceil.3
intro.1, _exit.2, access.2, alarm.2, alloc_hugepages.2, arch_prctl.2, bind.2, chdir...
[thirdparty/man-pages.git] / man3 / ceil.3
CommitLineData
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.\"
50831f9b 27.TH CEIL 3 2010-09-20 "" "Linux Programmer's Manual"
fea681da 28.SH NAME
c13182ef 29ceil, ceilf, ceill \- ceiling function: smallest integral value not
35478399 30less than argument
fea681da
MK
31.SH SYNOPSIS
32.nf
33.B #include <math.h>
34.sp
35.BI "double ceil(double " x );
36.br
37.BI "float ceilf(float " x );
38.br
39.BI "long double ceill(long double " x );
40.fi
41.sp
20c58d70 42Link with \fI\-lm\fP.
578d105f
MK
43.sp
44.in -4n
45Feature Test Macro Requirements for glibc (see
46.BR feature_test_macros (7)):
47.in
48.sp
49.ad l
50.BR ceilf (),
51.BR ceill ():
b90c43a8 52.RS 4
8b0d34e4
MK
53_BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE ||
54_POSIX_C_SOURCE\ >=\ 200112L;
b90c43a8
MK
55.br
56or
578d105f 57.I cc\ -std=c99
b90c43a8
MK
58.RE
59.ad
fea681da 60.SH DESCRIPTION
578d105f
MK
61These functions return the smallest integral value that is not less than
62.IR x .
63
64For example,
65.IR ceil(0.5)
66is 1.0, and
67.IR ceil(\-0.5)
68is 0.0.
47297adb 69.SH RETURN VALUE
578d105f
MK
70These functions return the ceiling of
71.IR x .
72
73If \fIx\fP is integral, +0, \-0, NaN, or infinite,
fea681da
MK
74\fIx\fP itself is returned.
75.SH ERRORS
578d105f 76No errors occur.
efe294cb 77POSIX.1-2001 documents a range error for overflows, but see NOTES.
47297adb 78.SH CONFORMING TO
578d105f
MK
79C99, POSIX.1-2001.
80The variant returning
81.I double
82also conforms to
83SVr4, 4.3BSD, C89.
fea681da 84.SH NOTES
68e1685c 85SUSv2 and POSIX.1-2001 contain text about overflow (which might set
fea681da 86.I errno
a9b4ebbc
MK
87to
88.BR ERANGE ,
578d105f
MK
89or raise an
90.B FE_OVERFLOW
91exception).
fea681da
MK
92In practice, the result cannot overflow on any current machine,
93so this error-handling stuff is just nonsense.
578d105f 94.\" The POSIX.1-2001 APPLICATION USAGE SECTION discusses this point.
fea681da
MK
95(More precisely, overflow can happen only when the maximum value
96of the exponent is smaller than the number of mantissa bits.
578d105f
MK
97For the IEEE-754 standard 32-bit and 64-bit floating-point numbers
98the maximum value of the exponent is 128 (respectively, 1024),
99and the number of mantissa bits is 24 (respectively, 53).)
100
101The integral value returned by these functions may be too large
102to store in an integer type
103.RI ( int ,
104.IR long ,
105etc.).
106To avoid an overflow, which will produce undefined results,
107an application should perform a range check on the returned value
108before assigning it to an integer type.
47297adb 109.SH SEE ALSO
fea681da
MK
110.BR floor (3),
111.BR lrint (3),
112.BR nearbyint (3),
113.BR rint (3),
114.BR round (3),
115.BR trunc (3)