1FLOOR(3P) POSIX Programmer's Manual FLOOR(3P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
12 floor, floorf, floorl - floor function
13
15 #include <math.h>
16
17 double floor(double x);
18 float floorf(float x);
19 long double floorl(long double x);
20
21
23 These functions shall compute the largest integral value not greater
24 than x.
25
26 An application wishing to check for error situations should set errno
27 to zero and call feclearexcept(FE_ALL_EXCEPT) before calling these
28 functions. On return, if errno is non-zero or fetestexcept(FE_INVALID
29 | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero, an error has
30 occurred.
31
33 Upon successful completion, these functions shall return the largest
34 integral value not greater than x, expressed as a double, float, or
35 long double, as appropriate for the return type of the function.
36
37 If x is NaN, a NaN shall be returned.
38
39 If x is ±0 or ±Inf, x shall be returned.
40
41 If the correct value would cause overflow, a range error shall occur
42 and floor(), floorf(), and floorl() shall return the value of the macro
43 -HUGE_VAL, -HUGE_VALF, and -HUGE_VALL, respectively.
44
46 These functions shall fail if:
47
48 Range Error
49 The result would cause an overflow.
50
51 If the integer expression (math_errhandling & MATH_ERRNO) is non-zero,
52 then errno shall be set to [ERANGE]. If the integer expression
53 (math_errhandling & MATH_ERREXCEPT) is non-zero, then the overflow
54 floating-point exception shall be raised.
55
56
57 The following sections are informative.
58
60 None.
61
63 The integral value returned by these functions might not be expressible
64 as an int or long. The return value should be tested before assigning
65 it to an integer type to avoid the undefined results of an integer
66 overflow.
67
68 The floor() function can only overflow when the floating-point repre‐
69 sentation has DBL_MANT_DIG > DBL_MAX_EXP.
70
71 On error, the expressions (math_errhandling & MATH_ERRNO) and
72 (math_errhandling & MATH_ERREXCEPT) are independent of each other, but
73 at least one of them must be non-zero.
74
76 None.
77
79 None.
80
82 ceil(), feclearexcept(), fetestexcept(), isnan(), the Base Definitions
83 volume of IEEE Std 1003.1-2001, Section 4.18, Treatment of Error Condi‐
84 tions for Mathematical Functions, <math.h>
85
87 Portions of this text are reprinted and reproduced in electronic form
88 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
89 -- Portable Operating System Interface (POSIX), The Open Group Base
90 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
91 Electrical and Electronics Engineers, Inc and The Open Group. In the
92 event of any discrepancy between this version and the original IEEE and
93 The Open Group Standard, the original IEEE and The Open Group Standard
94 is the referee document. The original Standard can be obtained online
95 at http://www.opengroup.org/unix/online.html .
96
97
98
99IEEE/The Open Group 2003 FLOOR(3P)