1FLOOR(P)                   POSIX Programmer's Manual                  FLOOR(P)
2
3
4

NAME

6       floor, floorf, floorl - floor function
7

SYNOPSIS

9       #include <math.h>
10
11       double floor(double x);
12       float floorf(float x);
13       long double floorl(long double x);
14
15

DESCRIPTION

17       These  functions  shall  compute the largest integral value not greater
18       than x.
19
20       An application wishing to check for error situations should  set  errno
21       to  zero  and  call  feclearexcept(FE_ALL_EXCEPT)  before calling these
22       functions.  On return, if errno is non-zero or  fetestexcept(FE_INVALID
23       |  FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero, an error has
24       occurred.
25

RETURN VALUE

27       Upon successful completion, these functions shall  return  the  largest
28       integral  value  not  greater  than x, expressed as a double, float, or
29       long double, as appropriate for the return type of the function.
30
31       If x is NaN, a NaN shall be returned.
32
33       If x is ±0 or ±Inf, x shall be returned.
34
35       If the correct value would cause overflow, a range  error  shall  occur
36       and floor(), floorf(), and floorl() shall return the value of the macro
37       -HUGE_VAL, -HUGE_VALF, and -HUGE_VALL, respectively.
38

ERRORS

40       These functions shall fail if:
41
42       Range Error
43              The result would cause an overflow.
44
45       If the integer expression (math_errhandling & MATH_ERRNO) is  non-zero,
46       then  errno  shall  be  set  to  [ERANGE].  If  the  integer expression
47       (math_errhandling & MATH_ERREXCEPT)  is  non-zero,  then  the  overflow
48       floating-point exception shall be raised.
49
50
51       The following sections are informative.
52

EXAMPLES

54       None.
55

APPLICATION USAGE

57       The integral value returned by these functions might not be expressible
58       as an int or long. The return value should be tested  before  assigning
59       it  to  an  integer  type  to avoid the undefined results of an integer
60       overflow.
61
62       The floor() function can only overflow when the  floating-point  repre‐
63       sentation has DBL_MANT_DIG > DBL_MAX_EXP.
64
65       On   error,   the   expressions  (math_errhandling  &  MATH_ERRNO)  and
66       (math_errhandling & MATH_ERREXCEPT) are independent of each other,  but
67       at least one of them must be non-zero.
68

RATIONALE

70       None.
71

FUTURE DIRECTIONS

73       None.
74

SEE ALSO

76       ceil()  , feclearexcept() , fetestexcept() , isnan() , the Base Defini‐
77       tions volume of IEEE Std 1003.1-2001, Section 4.18, Treatment of  Error
78       Conditions for Mathematical Functions, <math.h>
79
81       Portions  of  this text are reprinted and reproduced in electronic form
82       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
83       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
84       Specifications Issue 6, Copyright (C) 2001-2003  by  the  Institute  of
85       Electrical  and  Electronics  Engineers, Inc and The Open Group. In the
86       event of any discrepancy between this version and the original IEEE and
87       The  Open Group Standard, the original IEEE and The Open Group Standard
88       is the referee document. The original Standard can be  obtained  online
89       at http://www.opengroup.org/unix/online.html .
90
91
92
93IEEE/The Open Group                  2003                             FLOOR(P)
Impressum