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 */
52 SET_LDOUBLE_WORDS(x,esy&0x8000,0,1);/* return +-minsubnormal */
53 u = math_opt_barrier (x);
55 math_force_eval (u); /* raise underflow flag */
58 if(esx<0x8000) { /* x > 0 */
59 if(ix>iy||((ix==iy) && (hx>hy||((hx==hy)&&(lx>ly))))) {
66 } else { /* x < y, x += ulp */
75 if(esy>=0||(ix>iy||((ix==iy)&&(hx>hy||((hx==hy)&&(lx>ly)))))){
82 } else { /* x > y, x += ulp */
91 if(esy==0x7fff) return x+x; /* overflow */
93 long double u = x*x; /* underflow */
94 math_force_eval (u); /* raise underflow flag */
96 SET_LDOUBLE_WORDS(x,esx,hx,lx);
99 weak_alias (__nextafterl, nextafterl)
100 strong_alias (__nextafterl, __nexttowardl)
101 weak_alias (__nextafterl, nexttowardl)