1 /* s_ceill.c -- long double version of s_ceil.c.
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
12 * ====================================================
15 #if defined (LIBM_SCCS) && ! defined (lint)
16 static char rcsid
[] = "$NetBSD: $";
21 * Return x rounded toward -inf to integral value
26 #define NO_MATH_REDIRECT
28 #include <math_private.h>
29 #include <libm-alias-ldouble.h>
30 #include <math-use-builtins.h>
36 return __builtin_ceill (x
);
38 /* Use generic implementation. */
41 GET_LDOUBLE_WORDS64 (i0
, i1
, x
);
42 j0
= ((i0
>> 48) & 0x7fff) - 0x3fff;
47 /* return 0 * sign (x) if |x| < 1 */
50 i0
= 0x8000000000000000ULL
;
53 else if ((i0
| i1
) != 0)
55 i0
= 0x3fff000000000000ULL
;
61 i
= (0x0000ffffffffffffULL
) >> j0
;
62 if (((i0
& i
) | i1
) == 0)
63 return x
; /* x is integral */
65 i0
+= (0x0001000000000000LL
) >> j0
;
73 return x
+ x
; /* inf or NaN */
75 return x
; /* x is integral */
79 i
= -1ULL >> (j0
- 48);
81 return x
; /* x is integral */
88 j
= i1
+ (1LL << (112 - j0
));
90 i0
+= 1; /* got a carry */
96 SET_LDOUBLE_WORDS64 (x
, i0
, i1
);
98 #endif /* ! USE_CEILL_BUILTIN */
100 libm_alias_ldouble (__ceil
, ceil
)