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.
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 the next machine floating-point number of x in the
28 #include <math_private.h>
30 long double __nextafterl(long double x
, long double y
)
35 GET_LDOUBLE_WORDS64(hx
,lx
,x
);
36 GET_LDOUBLE_WORDS64(hy
,ly
,y
);
37 ix
= hx
&0x7fffffffffffffffLL
; /* |x| */
38 iy
= hy
&0x7fffffffffffffffLL
; /* |y| */
40 if(((ix
>=0x7fff000000000000LL
)&&((ix
-0x7fff000000000000LL
)|lx
)!=0) || /* x is nan */
41 ((iy
>=0x7fff000000000000LL
)&&((iy
-0x7fff000000000000LL
)|ly
)!=0)) /* y is nan */
43 if(x
==y
) return y
; /* x=y, return y */
44 if((ix
|lx
)==0) { /* x == 0 */
46 SET_LDOUBLE_WORDS64(x
,hy
&0x8000000000000000ULL
,1);/* return +-minsubnormal */
47 u
= math_opt_barrier (x
);
49 math_force_eval (u
); /* raise underflow flag */
52 if(hx
>=0) { /* x > 0 */
53 if(hx
>hy
||((hx
==hy
)&&(lx
>ly
))) { /* x > y, x -= ulp */
56 } else { /* x < y, x += ulp */
61 if(hy
>=0||hx
>hy
||((hx
==hy
)&&(lx
>ly
))){/* x < y, x -= ulp */
64 } else { /* x > y, x += ulp */
69 hy
= hx
&0x7fff000000000000LL
;
70 if(hy
==0x7fff000000000000LL
) {
71 long double u
= x
+ x
; /* overflow */
75 long double u
= x
*x
; /* underflow */
76 math_force_eval (u
); /* raise underflow flag */
78 SET_LDOUBLE_WORDS64(x
,hx
,lx
);
81 weak_alias (__nextafterl
, nextafterl
)
82 strong_alias (__nextafterl
, __nexttowardl
)
83 weak_alias (__nextafterl
, nexttowardl
)