Debian Codegraph @

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