Debian Codegraph @

upstream/debian-unstable/man3/ceil.3

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