1 /* s_nextafterl.c -- long double version of s_nextafter.c.
2 * Special version for i387.
3 * Conversion to long double by Ulrich Drepper,
4 * Cygnus Support, drepper@cygnus.com.
8 * ====================================================
9 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
11 * Developed at SunPro, a Sun Microsystems, Inc. business.
12 * Permission to use, copy, modify, and distribute this
13 * software is freely granted, provided that this notice
15 * ====================================================
18 #if defined(LIBM_SCCS) && !defined(lint)
19 static char rcsid
[] = "$NetBSD: $";
24 * return the next machine floating-point number of x in the
30 #include "math_private.h"
33 long double __nextafterl(long double x
, long double y
)
35 long double __nextafterl(x
,y
)
39 u_int32_t hx
,hy
,ix
,iy
;
43 GET_LDOUBLE_WORDS(esx
,hx
,lx
,x
);
44 GET_LDOUBLE_WORDS(esy
,hy
,ly
,y
);
45 ix
= esx
&0x7fff; /* |x| */
46 iy
= esy
&0x7fff; /* |y| */
48 /* Intel's extended format has the normally implicit 1 explicit
50 if(((ix
==0x7fff)&&(((hx
&0x7fffffff)|lx
)!=0)) || /* x is nan */
51 ((iy
==0x7fff)&&(((hy
&0x7fffffff)|ly
)!=0))) /* y is nan */
53 if(x
==y
) return y
; /* x=y, return y */
54 if((ix
|hx
|lx
)==0) { /* x == 0 */
55 SET_LDOUBLE_WORDS(x
,esy
&0x8000,0,1);/* return +-minsubnormal */
57 if(y
==x
) return y
; else return x
; /* raise underflow flag */
59 if(esx
>=0) { /* x > 0 */
60 if(esx
>esy
||((esx
==esy
) && (hx
>hy
||((hx
==hy
)&&(lx
>ly
))))) {
63 if (hx
<= 0x80000000) {
76 } else { /* x < y, x += ulp */
80 if (hx
==0 || (esx
== 0 && hx
== 0x80000000)) {
87 if(esy
>=0||(esx
>esy
||((esx
==esy
)&&(hx
>hy
||((hx
==hy
)&&(lx
>ly
)))))){
90 if (hx
<= 0x80000000) {
99 } else { /* x > y, x += ulp */
103 if (hx
==0 || (esx
== 0xffff8000 && hx
== 0x80000000)) {
111 if(esy
==0x7fff) return x
+x
; /* overflow */
112 if(esy
==0) { /* underflow */
114 if(y
!=x
) { /* raise underflow flag */
115 SET_LDOUBLE_WORDS(y
,esx
,hx
,lx
);
119 SET_LDOUBLE_WORDS(x
,esx
,hx
,lx
);
122 weak_alias (__nextafterl
, nextafterl
)
123 strong_alias (__nextafterl
, __nexttowardl
)
124 weak_alias (__nextafterl
, nexttowardl
)