OSDN Git Service

LDP: Update original to LDP v3.68
[linuxjm/LDP_man-pages.git] / original / 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 .\" %%%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  2013-06-21 "" "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 .sp
35 .BI "double ceil(double " x );
36 .br
37 .BI "float ceilf(float " x );
38 .br
39 .BI "long double ceill(long double " x );
40 .fi
41 .sp
42 Link with \fI\-lm\fP.
43 .sp
44 .in -4n
45 Feature Test Macro Requirements for glibc (see
46 .BR feature_test_macros (7)):
47 .in
48 .sp
49 .ad l
50 .BR ceilf (),
51 .BR ceill ():
52 .RS 4
53 _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE ||
54 _POSIX_C_SOURCE\ >=\ 200112L;
55 .br
56 or
57 .I cc\ -std=c99
58 .RE
59 .ad
60 .SH DESCRIPTION
61 These functions return the smallest integral value that is not less than
62 .IR x .
63
64 For example,
65 .IR ceil(0.5)
66 is 1.0, and
67 .IR ceil(\-0.5)
68 is 0.0.
69 .SH RETURN VALUE
70 These functions return the ceiling of
71 .IR x .
72
73 If
74 .I x
75 is integral, +0, \-0, NaN, or infinite,
76 .I x
77 itself is returned.
78 .SH ERRORS
79 No errors occur.
80 POSIX.1-2001 documents a range error for overflows, but see NOTES.
81 .SH ATTRIBUTES
82 .SS Multithreading (see pthreads(7))
83 The
84 .BR ceil (),
85 .BR ceilf (),
86 and
87 .BR ceill ()
88 functions are thread-safe.
89 .SH CONFORMING TO
90 C99, POSIX.1-2001.
91 The variant returning
92 .I double
93 also conforms to
94 SVr4, 4.3BSD, C89.
95 .SH NOTES
96 SUSv2 and POSIX.1-2001 contain text about overflow (which might set
97 .I errno
98 to
99 .BR ERANGE ,
100 or raise an
101 .B FE_OVERFLOW
102 exception).
103 In practice, the result cannot overflow on any current machine,
104 so this error-handling stuff is just nonsense.
105 .\" The POSIX.1-2001 APPLICATION USAGE SECTION discusses this point.
106 (More precisely, overflow can happen only when the maximum value
107 of the exponent is smaller than the number of mantissa bits.
108 For the IEEE-754 standard 32-bit and 64-bit floating-point numbers
109 the maximum value of the exponent is 128 (respectively, 1024),
110 and the number of mantissa bits is 24 (respectively, 53).)
111
112 The integral value returned by these functions may be too large
113 to store in an integer type
114 .RI ( int ,
115 .IR long ,
116 etc.).
117 To avoid an overflow, which will produce undefined results,
118 an application should perform a range check on the returned value
119 before assigning it to an integer type.
120 .SH SEE ALSO
121 .BR floor (3),
122 .BR lrint (3),
123 .BR nearbyint (3),
124 .BR rint (3),
125 .BR round (3),
126 .BR trunc (3)
127 .SH COLOPHON
128 This page is part of release 3.68 of the Linux
129 .I man-pages
130 project.
131 A description of the project,
132 information about reporting bugs,
133 and the latest version of this page,
134 can be found at
135 \%http://www.kernel.org/doc/man\-pages/.