Mercurial > hg > CbC > CbC_gcc
comparison libquadmath/math/ceilq.c @ 68:561a7518be6b
update gcc-4.6
author | Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 21 Aug 2011 07:07:55 +0900 |
parents | |
children | 04ced10e8804 |
comparison
equal
deleted
inserted
replaced
67:f6334be47118 | 68:561a7518be6b |
---|---|
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. | |
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 "quadmath-imp.h" | |
17 | |
18 static const __float128 huge = 1.0e4930Q; | |
19 | |
20 __float128 | |
21 ceilq (__float128 x) | |
22 { | |
23 int64_t i0,i1,j0; | |
24 uint64_t i,j; | |
25 GET_FLT128_WORDS64(i0,i1,x); | |
26 j0 = ((i0>>48)&0x7fff)-0x3fff; | |
27 if(j0<48) { | |
28 if(j0<0) { /* raise inexact if x != 0 */ | |
29 if(huge+x>0.0) {/* return 0*sign(x) if |x|<1 */ | |
30 if(i0<0) {i0=0x8000000000000000ULL;i1=0;} | |
31 else if((i0|i1)!=0) { i0=0x3fff000000000000ULL;i1=0;} | |
32 } | |
33 } else { | |
34 i = (0x0000ffffffffffffULL)>>j0; | |
35 if(((i0&i)|i1)==0) return x; /* x is integral */ | |
36 if(huge+x>0.0) { /* raise inexact flag */ | |
37 if(i0>0) i0 += (0x0001000000000000LL)>>j0; | |
38 i0 &= (~i); i1=0; | |
39 } | |
40 } | |
41 } else if (j0>111) { | |
42 if(j0==0x4000) return x+x; /* inf or NaN */ | |
43 else return x; /* x is integral */ | |
44 } else { | |
45 i = -1ULL>>(j0-48); | |
46 if((i1&i)==0) return x; /* x is integral */ | |
47 if(huge+x>0.0) { /* raise inexact flag */ | |
48 if(i0>0) { | |
49 if(j0==48) i0+=1; | |
50 else { | |
51 j = i1+(1LL<<(112-j0)); | |
52 if(j<i1) i0 +=1 ; /* got a carry */ | |
53 i1=j; | |
54 } | |
55 } | |
56 i1 &= (~i); | |
57 } | |
58 } | |
59 SET_FLT128_WORDS64(x,i0,i1); | |
60 return x; | |
61 } |