1 /* s_nexttowardf.c -- float version of s_nextafter.c.
2 * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com
3 * and Jakub Jelinek, jj@ultra.linux.cz.
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 #include <math_private.h>
25 float __nexttowardf(float x
, long double y
)
32 GET_LDOUBLE_WORDS64(hy
,ly
,y
);
33 ix
= hx
&0x7fffffff; /* |x| */
34 iy
= hy
&0x7fffffffffffffffLL
; /* |y| */
36 if((ix
>0x7f800000) || /* x is nan */
37 ((iy
>=0x7fff000000000000LL
)&&((iy
-0x7fff000000000000LL
)|ly
)!=0))
40 if((long double) x
==y
) return y
; /* x=y, return y */
41 if(ix
==0) { /* x == 0 */
43 SET_FLOAT_WORD(x
,(u_int32_t
)((hy
>>32)&0x80000000)|1);/* return +-minsub*/
44 u
= math_opt_barrier (x
);
46 math_force_eval (u
); /* raise underflow flag */
49 if(hx
>=0) { /* x > 0 */
50 if(x
> y
) { /* x -= ulp */
52 } else { /* x < y, x += ulp */
56 if(x
< y
) { /* x < y, x -= ulp */
58 } else { /* x > y, x += ulp */
64 float u
= x
+x
; /* overflow */
69 float u
= x
*x
; /* underflow */
70 math_force_eval (u
); /* raise underflow flag */
76 weak_alias (__nexttowardf
, nexttowardf
)