]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/ceil.3
CPU_SET.3, INFINITY.3, __ppc_get_timebase.3, __ppc_set_ppr_med.3, __ppc_yield.3,...
[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.\"
97986708 27.TH CEIL 3 2016-03-15 "" "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>
68e4db0a 34.PP
fea681da
MK
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
68e4db0a 41.PP
20c58d70 42Link with \fI\-lm\fP.
68e4db0a 43.PP
578d105f
MK
44.in -4n
45Feature Test Macro Requirements for glibc (see
46.BR feature_test_macros (7)):
47.in
68e4db0a 48.PP
578d105f
MK
49.ad l
50.BR ceilf (),
51.BR ceill ():
b90c43a8 52.RS 4
e9d91bcf
MK
53_ISOC99_SOURCE || _POSIX_C_SOURCE\ >=\ 200112L
54 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
55 || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
b90c43a8
MK
56.RE
57.ad
fea681da 58.SH DESCRIPTION
578d105f
MK
59These functions return the smallest integral value that is not less than
60.IR x .
847e0d88 61.PP
578d105f
MK
62For example,
63.IR ceil(0.5)
64is 1.0, and
65.IR ceil(\-0.5)
66is 0.0.
47297adb 67.SH RETURN VALUE
578d105f
MK
68These functions return the ceiling of
69.IR x .
847e0d88 70.PP
022671eb
MK
71If
72.I x
73is integral, +0, \-0, NaN, or infinite,
74.I x
75itself is returned.
fea681da 76.SH ERRORS
578d105f 77No errors occur.
efe294cb 78POSIX.1-2001 documents a range error for overflows, but see NOTES.
ea32445b 79.SH ATTRIBUTES
9b6495b4
MK
80For an explanation of the terms used in this section, see
81.BR attributes (7).
82.TS
83allbox;
84lbw24 lb lb
85l l l.
86Interface Attribute Value
87T{
ea32445b 88.BR ceil (),
ed21d749 89.BR ceilf (),
ea32445b 90.BR ceill ()
9b6495b4
MK
91T} Thread safety MT-Safe
92.TE
47297adb 93.SH CONFORMING TO
9a74e018 94C99, POSIX.1-2001, POSIX.1-2008.
847e0d88 95.PP
578d105f
MK
96The variant returning
97.I double
98also conforms to
99SVr4, 4.3BSD, C89.
fea681da 100.SH NOTES
68e1685c 101SUSv2 and POSIX.1-2001 contain text about overflow (which might set
fea681da 102.I errno
a9b4ebbc
MK
103to
104.BR ERANGE ,
578d105f
MK
105or raise an
106.B FE_OVERFLOW
107exception).
fea681da
MK
108In practice, the result cannot overflow on any current machine,
109so this error-handling stuff is just nonsense.
578d105f 110.\" The POSIX.1-2001 APPLICATION USAGE SECTION discusses this point.
fea681da
MK
111(More precisely, overflow can happen only when the maximum value
112of the exponent is smaller than the number of mantissa bits.
578d105f
MK
113For the IEEE-754 standard 32-bit and 64-bit floating-point numbers
114the maximum value of the exponent is 128 (respectively, 1024),
115and the number of mantissa bits is 24 (respectively, 53).)
847e0d88 116.PP
578d105f
MK
117The integral value returned by these functions may be too large
118to store in an integer type
119.RI ( int ,
120.IR long ,
121etc.).
122To avoid an overflow, which will produce undefined results,
123an application should perform a range check on the returned value
124before assigning it to an integer type.
47297adb 125.SH SEE ALSO
fea681da
MK
126.BR floor (3),
127.BR lrint (3),
128.BR nearbyint (3),
129.BR rint (3),
130.BR round (3),
131.BR trunc (3)