1FLOOR(3M) FLOOR(3M)
2
3
4
6 fabs, floor, ceil, rint - absolute value, floor, ceiling, and round-to-
7 nearest functions
8
10 #include <math.h>
11
12 double floor(x)
13 double x;
14
15 double ceil(x)
16 double x;
17
18 double fabs(x)
19 double x;
20
21 double rint(x)
22 double x;
23
25 Fabs returns the absolute value |x|.
26
27 Floor returns the largest integer no greater than x.
28
29 Ceil returns the smallest integer no less than x.
30
31 Rint returns the integer (represented as a double precision number)
32 nearest x in the direction of the prevailing rounding mode.
33
35 On a VAX, rint(x) is equivalent to adding half to the magnitude and
36 then rounding towards zero.
37
38 In the default rounding mode, to nearest, on a machine that conforms to
39 IEEE 754, rint(x) is the integer nearest x with the additional stipula‐
40 tion that if |rint(x)-x|=1/2 then rint(x) is even. Other rounding
41 modes can make rint act like floor, or like ceil, or round towards
42 zero.
43
44 Another way to obtain an integer near x is to declare (in C)
45 double x; int k; k = x;
46 Most C compilers round x towards 0 to get the integer k, but some do
47 otherwise. If in doubt, use floor, ceil, or rint first, whichever you
48 intend. Also note that, if x is larger than k can accommodate, the
49 value of k and the presence or absence of an integer overflow are hard
50 to predict.
51
53 abs(3), ieee(3M), math(3M)
54
55
56
574th Berkeley Distribution May 12, 1986 FLOOR(3M)