Debian Codegraph @

upstream/debian-trixie/man3/ceil.3

raw
1 '\" t
2 .\" Copyright 2001 Andries Brouwer <[email protected]>.
3 .\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk
4 .\" <[email protected]>
5 .\"
6 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
7 .\"
8 .TH ceil 3 2024-06-16 "Linux man-pages 6.9.1"
9 .SH NAME
10 ceil, ceilf, ceill \- ceiling function: smallest integral value not
11 less than argument
12 .SH LIBRARY
13 Math library
14 .RI ( libm ", " \-lm )
15 .SH SYNOPSIS
16 .nf
17 .B #include <math.h>
18 .P
19 .BI "double ceil(double " x );
20 .BI "float ceilf(float " x );
21 .BI "long double ceill(long double " x );
22 .fi
23 .P
24 .RS -4
25 Feature Test Macro Requirements for glibc (see
26 .BR feature_test_macros (7)):
27 .RE
28 .P
29 .BR ceilf (),
30 .BR ceill ():
31 .nf
32 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
33 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
34 || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
35 .fi
36 .SH DESCRIPTION
37 These functions return the smallest integral value that is not less than
38 .IR x .
39 .P
40 For example,
41 .I ceil(0.5)
42 is 1.0, and
43 .I ceil(\-0.5)
44 is 0.0.
45 .SH RETURN VALUE
46 These functions return the ceiling of
47 .IR x .
48 .P
49 If
50 .I x
51 is integral, +0, \-0, NaN, or infinite,
52 .I x
53 itself is returned.
54 .SH ERRORS
55 No errors occur.
56 .SH ATTRIBUTES
57 For an explanation of the terms used in this section, see
58 .BR attributes (7).
59 .TS
60 allbox;
61 lbx lb lb
62 l l l.
63 Interface Attribute Value
64 T{
65 .na
66 .nh
67 .BR ceil (),
68 .BR ceilf (),
69 .BR ceill ()
70 T} Thread safety MT-Safe
71 .TE
72 .SH STANDARDS
73 C11, POSIX.1-2008.
74 .SH HISTORY
75 C99, POSIX.1-2001.
76 .P
77 The variant returning
78 .I double
79 also conforms to
80 SVr4, 4.3BSD, C89.
81 .P
82 SUSv2 and POSIX.1-2001 contain text about overflow (which might set
83 .I errno
84 to
85 .BR ERANGE ,
86 or raise an
87 .B FE_OVERFLOW
88 exception).
89 In practice, the result cannot overflow on any current machine,
90 so this error-handling stuff was just nonsense.
91 .\" The POSIX.1-2001 APPLICATION USAGE SECTION discusses this point.
92 (More precisely, overflow can happen only when the maximum value
93 of the exponent is smaller than the number of mantissa bits.
94 For the IEEE-754 standard 32-bit and 64-bit floating-point numbers
95 the maximum value of the exponent is 127 (respectively, 1023),
96 and the number of mantissa bits
97 including the implicit bit
98 is 24 (respectively, 53).)
99 This was removed in POSIX.1-2008.
100 .P
101 The integral value returned by these functions may be too large
102 to store in an integer type
103 .RI ( int ,
104 .IR long ,
105 etc.).
106 To avoid an overflow, which will produce undefined results,
107 an application should perform a range check on the returned value
108 before assigning it to an integer type.
109 .SH SEE ALSO
110 .BR floor (3),
111 .BR lrint (3),
112 .BR nearbyint (3),
113 .BR rint (3),
114 .BR round (3),
115 .BR trunc (3)