1/* s_ceilf.c -- float version of s_ceil.c.
2 */
3
4/*
5 * ====================================================
6 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
7 *
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 * ====================================================
13 */
14
15#define NO_MATH_REDIRECT
16#include <math.h>
17#include <math_private.h>
18#include <libm-alias-float.h>
19#include <math-use-builtins.h>
20
21float
22__ceilf (float x)
23{
24#if USE_CEILF_BUILTIN
25 return __builtin_ceilf (x);
26#else
27 /* Use generic implementation. */
28 int32_t i0, j0;
29 uint32_t i;
30
31 GET_FLOAT_WORD (i0, x);
32 j0 = ((i0 >> 23) & 0xff) - 0x7f;
33 if (j0 < 23)
34 {
35 if (j0 < 0)
36 {
37 /* return 0 * sign (x) if |x| < 1 */
38 if (i0 < 0)
39 i0 = 0x80000000;
40 else if (i0 != 0)
41 i0 = 0x3f800000;
42 }
43 else
44 {
45 i = (0x007fffff) >> j0;
46 if ((i0 & i) == 0)
47 return x; /* x is integral */
48 if (i0 > 0)
49 i0 += (0x00800000) >> j0;
50 i0 &= (~i);
51 }
52 }
53 else
54 {
55 if (__glibc_unlikely (j0 == 0x80))
56 return x + x; /* inf or NaN */
57 else
58 return x; /* x is integral */
59 }
60 SET_FLOAT_WORD (x, i0);
61 return x;
62#endif /* ! USE_CEILF_BUILTIN */
63}
64#ifndef __ceilf
65libm_alias_float (__ceil, ceil)
66#endif
67

source code of glibc/sysdeps/ieee754/flt-32/s_ceilf.c