]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/ceil.3
Many pages: Use correct letter case in page titles (TH)
[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.\"
5fbde956 5.\" SPDX-License-Identifier: Linux-man-pages-copyleft
fea681da 6.\"
4c1c5274 7.TH ceil 3 (date) "Linux man-pages (unreleased)"
fea681da 8.SH NAME
c13182ef 9ceil, ceilf, ceill \- ceiling function: smallest integral value not
35478399 10less than argument
2af19291
AC
11.SH LIBRARY
12Math 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
24Feature 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
36These functions return the smallest integral value that is not less than
37.IR x .
847e0d88 38.PP
578d105f 39For example,
1ae6b2c7 40.I ceil(0.5)
578d105f 41is 1.0, and
1ae6b2c7 42.I ceil(\-0.5)
578d105f 43is 0.0.
47297adb 44.SH RETURN VALUE
578d105f
MK
45These functions return the ceiling of
46.IR x .
847e0d88 47.PP
022671eb
MK
48If
49.I x
50is integral, +0, \-0, NaN, or infinite,
51.I x
52itself is returned.
fea681da 53.SH ERRORS
578d105f 54No errors occur.
efe294cb 55POSIX.1-2001 documents a range error for overflows, but see NOTES.
ea32445b 56.SH ATTRIBUTES
9b6495b4
MK
57For 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
62allbox;
c466875e 63lbx lb lb
9b6495b4
MK
64l l l.
65Interface Attribute Value
66T{
ea32445b 67.BR ceil (),
ed21d749 68.BR ceilf (),
ea32445b 69.BR ceill ()
9b6495b4
MK
70T} Thread safety MT-Safe
71.TE
c466875e
MK
72.hy
73.ad
74.sp 1
3113c7f3 75.SH STANDARDS
9a74e018 76C99, POSIX.1-2001, POSIX.1-2008.
847e0d88 77.PP
578d105f
MK
78The variant returning
79.I double
80also conforms to
81SVr4, 4.3BSD, C89.
fea681da 82.SH NOTES
68e1685c 83SUSv2 and POSIX.1-2001 contain text about overflow (which might set
fea681da 84.I errno
a9b4ebbc
MK
85to
86.BR ERANGE ,
578d105f
MK
87or raise an
88.B FE_OVERFLOW
89exception).
fea681da
MK
90In practice, the result cannot overflow on any current machine,
91so 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
94of the exponent is smaller than the number of mantissa bits.
578d105f 95For the IEEE-754 standard 32-bit and 64-bit floating-point numbers
24e0e193
AC
96the maximum value of the exponent is 127 (respectively, 1023),
97and the number of mantissa bits
98including the implicit bit
99is 24 (respectively, 53).)
847e0d88 100.PP
578d105f
MK
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)