Mercurial > hg > CbC > CbC_gcc
comparison libquadmath/math/nextafterq.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_nextafterl.c -- long double version of s_nextafter.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 __float128 | |
19 nextafterq (__float128 x, __float128 y) | |
20 { | |
21 int64_t hx,hy,ix,iy; | |
22 uint64_t lx,ly; | |
23 | |
24 GET_FLT128_WORDS64(hx,lx,x); | |
25 GET_FLT128_WORDS64(hy,ly,y); | |
26 ix = hx&0x7fffffffffffffffLL; /* |x| */ | |
27 iy = hy&0x7fffffffffffffffLL; /* |y| */ | |
28 | |
29 if(((ix>=0x7fff000000000000LL)&&((ix-0x7fff000000000000LL)|lx)!=0) || /* x is nan */ | |
30 ((iy>=0x7fff000000000000LL)&&((iy-0x7fff000000000000LL)|ly)!=0)) /* y is nan */ | |
31 return x+y; | |
32 if(x==y) return y; /* x=y, return y */ | |
33 if((ix|lx)==0) { /* x == 0 */ | |
34 SET_FLT128_WORDS64(x,hy&0x8000000000000000ULL,1);/* return +-minsubnormal */ | |
35 | |
36 /* here we should raise an underflow flag */ | |
37 return x; | |
38 } | |
39 if(hx>=0) { /* x > 0 */ | |
40 if(hx>hy||((hx==hy)&&(lx>ly))) { /* x > y, x -= ulp */ | |
41 if(lx==0) hx--; | |
42 lx--; | |
43 } else { /* x < y, x += ulp */ | |
44 lx++; | |
45 if(lx==0) hx++; | |
46 } | |
47 } else { /* x < 0 */ | |
48 if(hy>=0||hx>hy||((hx==hy)&&(lx>ly))){/* x < y, x -= ulp */ | |
49 if(lx==0) hx--; | |
50 lx--; | |
51 } else { /* x > y, x += ulp */ | |
52 lx++; | |
53 if(lx==0) hx++; | |
54 } | |
55 } | |
56 hy = hx&0x7fff000000000000LL; | |
57 if(hy==0x7fff000000000000LL) return x+x;/* overflow */ | |
58 if(hy==0) { | |
59 /* here we should raise an underflow flag */ | |
60 } | |
61 SET_FLT128_WORDS64(x,hx,lx); | |
62 return x; | |
63 } |