1 /* s_nextafterl.c -- long double version of s_nextafter.c.
2 * Conversion to long double by Ulrich Drepper,
3 * Cygnus Support, drepper@cygnus.com.
7 * ====================================================
8 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
10 * Developed at SunPro, a Sun Microsystems, Inc. business.
11 * Permission to use, copy, modify, and distribute this
12 * software is freely granted, provided that this notice
14 * ====================================================
17 #if defined(LIBM_SCCS) && !defined(lint)
18 static char rcsid
[] = "$NetBSD: $";
23 * return the next machine floating-point number of x in the
29 #include "math_private.h"
32 long double __nextafterl(long double x
, long double y
)
34 long double __nextafterl(x
,y
)
39 u_int32_t lx
,ly
,esx
,esy
;
41 GET_LDOUBLE_WORDS(esx
,hx
,lx
,x
);
42 GET_LDOUBLE_WORDS(esy
,hy
,ly
,y
);
43 ix
= esx
&0x7fff; /* |x| */
44 iy
= esy
&0x7fff; /* |y| */
46 if (((ix
==0x7fff)&&((hx
|lx
)!=0)) || /* x is nan */
47 ((iy
==0x7fff)&&((hy
|ly
)!=0))) /* y is nan */
49 if(x
==y
) return y
; /* x=y, return y */
50 if((ix
|hx
|lx
)==0) { /* x == 0 */
51 SET_LDOUBLE_WORDS(x
,esy
&0x8000,0,1);/* return +-minsubnormal */
53 if(y
==x
) return y
; else return x
; /* raise underflow flag */
55 if(esx
<0x8000) { /* x > 0 */
56 if(ix
>iy
||((ix
==iy
) && (hx
>hy
||((hx
==hy
)&&(lx
>ly
))))) {
63 } else { /* x < y, x += ulp */
72 if(esy
>=0||(ix
>iy
||((ix
==iy
)&&(hx
>hy
||((hx
==hy
)&&(lx
>ly
)))))){
79 } else { /* x > y, x += ulp */
88 if(esy
==0x7fff) return x
+x
; /* overflow */
89 if(esy
==0) { /* underflow */
91 if(y
!=x
) { /* raise underflow flag */
92 SET_LDOUBLE_WORDS(y
,esx
,hx
,lx
);
96 SET_LDOUBLE_WORDS(x
,esx
,hx
,lx
);
99 weak_alias (__nextafterl
, nextafterl
)
100 strong_alias (__nextafterl
, __nexttowardl
)
101 weak_alias (__nextafterl
, nexttowardl
)