mount_setattr.2: Further tweaks after feedback from Christian Brauner
[man-pages.git] / man3 / ceil.3
blob17f3ef1a2a7768ed83ce2bca52a17fffa13fc061
1 .\" Copyright 2001 Andries Brouwer <aeb@cwi.nl>.
2 .\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk
3 .\"     <mtk.manpages@gmail.com>
4 .\"
5 .\" %%%LICENSE_START(VERBATIM)
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.
14 .\"
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.
22 .\"
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" %%%LICENSE_END
26 .\"
27 .TH CEIL 3  2021-03-22 "" "Linux Programmer's Manual"
28 .SH NAME
29 ceil, ceilf, ceill \- ceiling function: smallest integral value not
30 less than argument
31 .SH SYNOPSIS
32 .nf
33 .B #include <math.h>
34 .PP
35 .BI "double ceil(double " x );
36 .BI "float ceilf(float " x );
37 .BI "long double ceill(long double " x );
38 .fi
39 .PP
40 Link with \fI\-lm\fP.
41 .PP
42 .RS -4
43 Feature Test Macro Requirements for glibc (see
44 .BR feature_test_macros (7)):
45 .RE
46 .PP
47 .BR ceilf (),
48 .BR ceill ():
49 .nf
50     _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
51         || /* Since glibc 2.19: */ _DEFAULT_SOURCE
52         || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
53 .fi
54 .SH DESCRIPTION
55 These functions return the smallest integral value that is not less than
56 .IR x .
57 .PP
58 For example,
59 .IR ceil(0.5)
60 is 1.0, and
61 .IR ceil(\-0.5)
62 is 0.0.
63 .SH RETURN VALUE
64 These functions return the ceiling of
65 .IR x .
66 .PP
68 .I x
69 is integral, +0, \-0, NaN, or infinite,
70 .I x
71 itself is returned.
72 .SH ERRORS
73 No errors occur.
74 POSIX.1-2001 documents a range error for overflows, but see NOTES.
75 .SH ATTRIBUTES
76 For an explanation of the terms used in this section, see
77 .BR attributes (7).
78 .ad l
79 .nh
80 .TS
81 allbox;
82 lbx lb lb
83 l l l.
84 Interface       Attribute       Value
86 .BR ceil (),
87 .BR ceilf (),
88 .BR ceill ()
89 T}      Thread safety   MT-Safe
90 .TE
91 .hy
92 .ad
93 .sp 1
94 .SH CONFORMING TO
95 C99, POSIX.1-2001, POSIX.1-2008.
96 .PP
97 The variant returning
98 .I double
99 also conforms to
100 SVr4, 4.3BSD, C89.
101 .SH NOTES
102 SUSv2 and POSIX.1-2001 contain text about overflow (which might set
103 .I errno
105 .BR ERANGE ,
106 or raise an
107 .B FE_OVERFLOW
108 exception).
109 In practice, the result cannot overflow on any current machine,
110 so this error-handling stuff is just nonsense.
111 .\" The POSIX.1-2001 APPLICATION USAGE SECTION discusses this point.
112 (More precisely, overflow can happen only when the maximum value
113 of the exponent is smaller than the number of mantissa bits.
114 For the IEEE-754 standard 32-bit and 64-bit floating-point numbers
115 the maximum value of the exponent is 128 (respectively, 1024),
116 and the number of mantissa bits is 24 (respectively, 53).)
118 The integral value returned by these functions may be too large
119 to store in an integer type
120 .RI ( int ,
121 .IR long ,
122 etc.).
123 To avoid an overflow, which will produce undefined results,
124 an application should perform a range check on the returned value
125 before assigning it to an integer type.
126 .SH SEE ALSO
127 .BR floor (3),
128 .BR lrint (3),
129 .BR nearbyint (3),
130 .BR rint (3),
131 .BR round (3),
132 .BR trunc (3)