]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/ceil.3
Many pages: Fix style issues reported by `make lint-groff`
[thirdparty/man-pages.git] / man3 / ceil.3
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 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\"
7 .TH CEIL 3 2021-03-22 GNU "Linux Programmer's Manual"
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 .PP
18 .BI "double ceil(double " x );
19 .BI "float ceilf(float " x );
20 .BI "long double ceill(long double " x );
21 .fi
22 .PP
23 .RS -4
24 Feature Test Macro Requirements for glibc (see
25 .BR feature_test_macros (7)):
26 .RE
27 .PP
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 .PP
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 .PP
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 POSIX.1-2001 documents a range error for overflows, but see NOTES.
56 .SH ATTRIBUTES
57 For an explanation of the terms used in this section, see
58 .BR attributes (7).
59 .ad l
60 .nh
61 .TS
62 allbox;
63 lbx lb lb
64 l l l.
65 Interface Attribute Value
66 T{
67 .BR ceil (),
68 .BR ceilf (),
69 .BR ceill ()
70 T} Thread safety MT-Safe
71 .TE
72 .hy
73 .ad
74 .sp 1
75 .SH CONFORMING TO
76 C99, POSIX.1-2001, POSIX.1-2008.
77 .PP
78 The variant returning
79 .I double
80 also conforms to
81 SVr4, 4.3BSD, C89.
82 .SH NOTES
83 SUSv2 and POSIX.1-2001 contain text about overflow (which might set
84 .I errno
85 to
86 .BR ERANGE ,
87 or raise an
88 .B FE_OVERFLOW
89 exception).
90 In practice, the result cannot overflow on any current machine,
91 so this error-handling stuff is just nonsense.
92 .\" The POSIX.1-2001 APPLICATION USAGE SECTION discusses this point.
93 (More precisely, overflow can happen only when the maximum value
94 of the exponent is smaller than the number of mantissa bits.
95 For the IEEE-754 standard 32-bit and 64-bit floating-point numbers
96 the maximum value of the exponent is 128 (respectively, 1024),
97 and the number of mantissa bits is 24 (respectively, 53).)
98 .PP
99 The integral value returned by these functions may be too large
100 to store in an integer type
101 .RI ( int ,
102 .IR long ,
103 etc.).
104 To avoid an overflow, which will produce undefined results,
105 an application should perform a range check on the returned value
106 before assigning it to an integer type.
107 .SH SEE ALSO
108 .BR floor (3),
109 .BR lrint (3),
110 .BR nearbyint (3),
111 .BR rint (3),
112 .BR round (3),
113 .BR trunc (3)