1 /* s_ceill.c -- long double version of s_ceil.c.
2 * Conversion to IEEE quad long double by Jakub Jelinek, jj@ultra.linux.cz.
6 * ====================================================
7 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
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
13 * ====================================================
16 #if defined(LIBM_SCCS) && !defined(lint)
17 static char rcsid
[] = "$NetBSD: $";
22 * Return x rounded toward -inf to integral value
26 * Inexact flag raised if x not equal to ceil(x).
30 #include "math_private.h"
33 static const long double huge
= 1.0e4930
;
35 static long double huge
= 1.0e4930
;
39 long double __ceill(long double x
)
41 long double __ceill(x
)
47 GET_LDOUBLE_WORDS64(i0
,i1
,x
);
48 j0
= ((i0
>>48)&0x7fff)-0x3fff;
50 if(j0
<0) { /* raise inexact if x != 0 */
51 if(huge
+x
>0.0) {/* return 0*sign(x) if |x|<1 */
52 if(i0
<0) {i0
=0x8000000000000000ULL
;i1
=0;}
53 else if((i0
|i1
)!=0) { i0
=0x3fff000000000000ULL
;i1
=0;}
56 i
= (0x0000ffffffffffffULL
)>>j0
;
57 if(((i0
&i
)|i1
)==0) return x
; /* x is integral */
58 if(huge
+x
>0.0) { /* raise inexact flag */
59 if(i0
>0) i0
+= (0x0001000000000000LL
)>>j0
;
64 if(j0
==0x4000) return x
+x
; /* inf or NaN */
65 else return x
; /* x is integral */
68 if((i1
&i
)==0) return x
; /* x is integral */
69 if(huge
+x
>0.0) { /* raise inexact flag */
73 j
= i1
+(1LL<<(112-j0
));
74 if(j
<i1
) i0
+=1 ; /* got a carry */
81 SET_LDOUBLE_WORDS64(x
,i0
,i1
);
84 weak_alias (__ceill
, ceill
)