Debian Codegraph @

upstream/debian-trixie/man3/floor.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 floor 3 2024-06-16 "Linux man-pages 6.9.1"
9 .SH NAME
10 floor, floorf, floorl \- largest integral value not greater 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 floor(double " x );
19 .BI "float floorf(float " x );
20 .BI "long double floorl(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 floorf (),
29 .BR floorl ():
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 largest integral value that is not greater than
37 .IR x .
38 .P
39 For example,
40 .I floor(0.5)
41 is 0.0, and
42 .I floor(\-0.5)
43 is \-1.0.
44 .SH RETURN VALUE
45 These functions return the floor of
46 .IR x .
47 .P
48 If
49 .I x
50 is integral, +0, \-0, NaN, or an infinity,
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 floor (),
67 .BR floorf (),
68 .BR floorl ()
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 .SH SEE ALSO
100 .BR ceil (3),
101 .BR lrint (3),
102 .BR nearbyint (3),
103 .BR rint (3),
104 .BR round (3),
105 .BR trunc (3)