1 /* s_nexttowardf.c -- float version of s_nextafter.c.
2 * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
6 * ====================================================
7 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
9 * Developed at SunPro, a Sun Microsystems, Inc. business.
10 * Permission to use, copy, modify, and distribute this
11 * software is freely granted, provided that this notice
13 * ====================================================
16 #if defined(LIBM_SCCS) && !defined(lint)
17 static char rcsid
[] = "$NetBSD: $";
21 #include <math_private.h>
24 float __nexttowardf(float x
, long double y
)
30 GET_LDOUBLE_WORDS(esy
,hy
,ly
,y
);
31 ix
= hx
&0x7fffffff; /* |x| */
32 iy
= esy
&0x7fff; /* |y| */
34 if((ix
>0x7f800000) || /* x is nan */
35 (iy
>=0x7fff&&((hy
|ly
)!=0))) /* y is nan */
37 if((long double) x
==y
) return y
; /* x=y, return y */
38 if(ix
==0) { /* x == 0 */
40 SET_FLOAT_WORD(x
,((esy
&0x8000)<<16)|1);/* return +-minsub*/
41 u
= math_opt_barrier (x
);
43 math_force_eval (u
); /* raise underflow flag */
46 if(hx
>=0) { /* x > 0 */
47 if(x
> y
) { /* x -= ulp */
49 } else { /* x < y, x += ulp */
53 if(x
< y
) { /* x -= ulp */
55 } else { /* x > y, x += ulp */
61 x
= x
+x
; /* overflow */
62 if (FLT_EVAL_METHOD
!= 0)
63 /* Force conversion to float. */
68 float u
= x
*x
; /* underflow */
69 math_force_eval (u
); /* raise underflow flag */
74 weak_alias (__nexttowardf
, nexttowardf
)