OSDN Git Service

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