fixed more binutils issues (newer gcc/libc)
[zpugcc/jano.git] / toolchain / gcc / newlib / libm / mathfp / s_floor.c
blob0dbc207f3fc2adc5d835d30184b5126fbf204fb1
2 /* @(#)z_floor.c 1.0 98/08/13 */
4 /*
5 FUNCTION
6 <<floor>>, <<floorf>>, <<ceil>>, <<ceilf>>---floor and ceiling
7 INDEX
8 floor
9 INDEX
10 floorf
11 INDEX
12 ceil
13 INDEX
14 ceilf
16 ANSI_SYNOPSIS
17 #include <math.h>
18 double floor(double <[x]>);
19 float floorf(float <[x]>);
20 double ceil(double <[x]>);
21 float ceilf(float <[x]>);
23 TRAD_SYNOPSIS
24 #include <math.h>
25 double floor(<[x]>)
26 double <[x]>;
27 float floorf(<[x]>)
28 float <[x]>;
29 double ceil(<[x]>)
30 double <[x]>;
31 float ceilf(<[x]>)
32 float <[x]>;
34 DESCRIPTION
35 <<floor>> and <<floorf>> find
36 @tex
37 $\lfloor x \rfloor$,
38 @end tex
39 the nearest integer less than or equal to <[x]>.
40 <<ceil>> and <<ceilf>> find
41 @tex
42 $\lceil x\rceil$,
43 @end tex
44 the nearest integer greater than or equal to <[x]>.
46 RETURNS
47 <<floor>> and <<ceil>> return the integer result as a double.
48 <<floorf>> and <<ceilf>> return the integer result as a float.
50 PORTABILITY
51 <<floor>> and <<ceil>> are ANSI.
52 <<floorf>> and <<ceilf>> are extensions.
56 /*****************************************************************
57 * floor
59 * Input:
60 * x - floating point value
62 * Output:
63 * Smallest integer less than x.
65 * Description:
66 * This routine returns the smallest integer less than x.
68 *****************************************************************/
70 #include "fdlibm.h"
71 #include "zmath.h"
73 #ifndef _DOUBLE_IS_32BITS
75 double
76 _DEFUN (floor, (double),
77 double x)
79 double f, y;
81 if (x > -1.0 && x < 1.0)
82 return (x >= 0 ? 0 : -1.0);
84 y = modf (x, &f);
86 if (y == 0.0)
87 return (x);
89 return (x >= 0 ? f : f - 1.0);
92 #endif /* _DOUBLE_IS_32BITS */