1 /* origin: FreeBSD /usr/src/lib/msun/src/s_ceil.c */
3 * ====================================================
4 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
6 * Developed at SunPro, a Sun Microsystems, Inc. business.
7 * Permission to use, copy, modify, and distribute this
8 * software is freely granted, provided that this notice
10 * ====================================================
14 * Return x rounded toward -inf to integral value
18 * Inexact flag raised if x not equal to ceil(x).
23 static const double huge = 1.0e300;
30 EXTRACT_WORDS(i0, i1, x);
32 j0 = ((i0>>20)&0x7ff) - 0x3ff;
35 /* raise inexact if x != 0 */
37 /* return 0*sign(x) if |x|<1 */
41 } else if ((i0|i1) != 0) {
48 if (((i0&i)|i1) == 0) /* x is integral */
50 /* raise inexact flag */
59 if (j0 == 0x400) /* inf or NaN */
61 return x; /* x is integral */
63 i = (uint32_t)0xffffffff>>(j0-20);
65 return x; /* x is integral */
66 /* raise inexact flag */
72 j = i1 + (1<<(52-j0));
73 if (j < i1) /* got a carry */
81 INSERT_WORDS(x, i0, i1);