1 /* sf_ceil.c -- float version of s_ceil.c.
2  * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
3  */
4 
5 /*
6  * ====================================================
7  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
8  *
9  * Developed at SunPro, a Sun Microsystems, Inc. business.
10  * Permission to use, copy, modify, and distribute this
11  * software is freely granted, provided that this notice
12  * is preserved.
13  * ====================================================
14  */
15 
16 #include "fdlibm.h"
17 
18 float
ceilf(float x)19 ceilf(float x)
20 {
21     __int32_t i0, j0;
22     __uint32_t i, ix;
23     GET_FLOAT_WORD(i0, x);
24     ix = (i0 & 0x7fffffff);
25     j0 = (ix >> 23) - 0x7f;
26     if (j0 < 23) {
27         if (j0 < 0) {
28             if (i0 < 0) {
29                 i0 = 0x80000000;
30             } else if (!FLT_UWORD_IS_ZERO(ix)) {
31                 i0 = 0x3f800000;
32             }
33         } else {
34             i = (0x007fffff) >> j0;
35             if ((i0 & i) == 0)
36                 return x; /* x is integral */
37             if (i0 > 0)
38                 i0 += (0x00800000) >> j0;
39             i0 &= (~i);
40         }
41     } else {
42         if (!FLT_UWORD_IS_FINITE(ix))
43             return x + x; /* inf or NaN */
44         else
45             return x; /* x is integral */
46     }
47     SET_FLOAT_WORD(x, i0);
48     return x;
49 }
50 
51 _MATH_ALIAS_f_f(ceil)
52