1 /* nextafterq.c -- __float128 version of s_nextafter.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 * ====================================================
17 #include "quadmath-imp.h"
20 nextafterq (__float128 x
, __float128 y
)
25 GET_FLT128_WORDS64(hx
,lx
,x
);
26 GET_FLT128_WORDS64(hy
,ly
,y
);
27 ix
= hx
&0x7fffffffffffffffLL
; /* |x| */
28 iy
= hy
&0x7fffffffffffffffLL
; /* |y| */
30 if(((ix
>=0x7fff000000000000LL
)&&((ix
-0x7fff000000000000LL
)|lx
)!=0) || /* x is nan */
31 ((iy
>=0x7fff000000000000LL
)&&((iy
-0x7fff000000000000LL
)|ly
)!=0)) /* y is nan */
33 if(x
==y
) return y
; /* x=y, return y */
34 if((ix
|lx
)==0) { /* x == 0 */
35 SET_FLT128_WORDS64(x
,hy
&0x8000000000000000ULL
,1);/* return +-minsubnormal */
37 /* here we should raise an underflow flag */
40 if(hx
>=0) { /* x > 0 */
41 if(hx
>hy
||((hx
==hy
)&&(lx
>ly
))) { /* x > y, x -= ulp */
44 } else { /* x < y, x += ulp */
49 if(hy
>=0||hx
>hy
||((hx
==hy
)&&(lx
>ly
))){/* x < y, x -= ulp */
52 } else { /* x > y, x += ulp */
57 hy
= hx
&0x7fff000000000000LL
;
58 if(hy
==0x7fff000000000000LL
) {
59 __float128 u
= x
+ x
; /* overflow */
64 __float128 u
= x
*x
; /* underflow */
65 math_force_eval (u
); /* raise underflow flag */
68 SET_FLT128_WORDS64(x
,hx
,lx
);