elf: Ignore LD_LIBRARY_PATH and debug env var for setuid for static
[glibc.git] / sysdeps / ieee754 / flt-32 / s_floorf.c
bloba5c38818f1f23ad495f560c673b41796511f9363
1 /* s_floorf.c -- float version of s_floor.c.
2 */
4 /*
5 * ====================================================
6 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
8 * Developed at SunPro, a Sun Microsystems, Inc. business.
9 * Permission to use, copy, modify, and distribute this
10 * software is freely granted, provided that this notice
11 * is preserved.
12 * ====================================================
16 * floorf(x)
17 * Return x rounded toward -inf to integral value
18 * Method:
19 * Bit twiddling.
22 #define NO_MATH_REDIRECT
23 #include <math.h>
24 #include <math_private.h>
25 #include <libm-alias-float.h>
26 #include <math-use-builtins.h>
28 float
29 __floorf (float x)
31 #if USE_FLOORF_BUILTIN
32 return __builtin_floorf (x);
33 #else
34 /* Use generic implementation. */
35 int32_t i0, j0;
36 uint32_t i;
37 GET_FLOAT_WORD (i0, x);
38 j0 = ((i0 >> 23) & 0xff) - 0x7f;
39 if (j0 < 23)
41 if (j0 < 0)
43 /* return 0 * sign (x) if |x| < 1 */
44 if (i0 >= 0)
45 i0 = 0;
46 else if ((i0 & 0x7fffffff) != 0)
47 i0 = 0xbf800000;
49 else
51 i = (0x007fffff) >> j0;
52 if ((i0 & i) == 0)
53 return x; /* x is integral */
54 if (i0 < 0)
55 i0 += (0x00800000) >> j0;
56 i0 &= (~i);
59 else
61 if (__glibc_unlikely (j0 == 0x80))
62 return x + x; /* inf or NaN */
63 else
64 return x; /* x is integral */
66 SET_FLOAT_WORD (x, i0);
67 return x;
68 #endif /* ! USE_FLOORF_BUILTIN */
70 #ifndef __floorf
71 libm_alias_float (__floor, floor)
72 #endif