]>
git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/i386/fpu/s_nexttowardf.c
1 /* s_nexttowardf.c -- float version of s_nextafter.c.
2 * Special i387 version.
3 * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@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: $";
22 #include <math_private.h>
26 float __nexttowardf(float x
, long double y
)
28 float __nexttowardf(x
,y
)
37 GET_LDOUBLE_WORDS(esy
,hy
,ly
,y
);
38 ix
= hx
&0x7fffffff; /* |x| */
39 iy
= esy
&0x7fff; /* |y| */
41 /* Intel's extended format has the normally implicit 1 explicit
43 if((ix
>0x7f800000) || /* x is nan */
44 (iy
>=0x7fff&&(((hy
&0x7fffffff)|ly
)!=0))) /* y is nan */
46 if((long double) x
==y
) return y
; /* x=y, return y */
47 if(ix
==0) { /* x == 0 */
49 SET_FLOAT_WORD(x
,((esy
&0x8000)<<16)|1);/* return +-minsub*/
50 u
= math_opt_barrier (x
);
52 math_force_eval (u
); /* raise underflow flag */
55 if(hx
>=0) { /* x > 0 */
56 if(esy
>=0x8000||((ix
>>23)&0xff)>iy
-0x3f80
57 || (((ix
>>23)&0xff)==iy
-0x3f80
58 && ((ix
&0x7fffff)<<8)>(hy
&0x7fffffff))) {/* x > y, x -= ulp */
60 } else { /* x < y, x += ulp */
64 if(esy
<0x8000||((ix
>>23)&0xff)>iy
-0x3f80
65 || (((ix
>>23)&0xff)==iy
-0x3f80
66 && ((ix
&0x7fffff)<<8)>(hy
&0x7fffffff))) {/* x < y, x -= ulp */
68 } else { /* x > y, x += ulp */
74 x
= x
+x
; /* overflow */
75 if (FLT_EVAL_METHOD
!= 0)
76 /* Force conversion to float. */
81 float u
= x
*x
; /* underflow */
82 math_force_eval (u
); /* raise underflow flag */
87 weak_alias (__nexttowardf
, nexttowardf
)