1 /* Single precision version of nexttoward.c.
2 Conversion to IEEE single float by Jakub Jelinek, jj@ultra.linux.cz. */
4 * ====================================================
5 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
7 * Developed at SunPro, a Sun Microsystems, Inc. business.
8 * Permission to use, copy, modify, and distribute this
9 * software is freely granted, provided that this notice
11 * ====================================================
16 * return the next machine floating-point number of x in the
18 * This is for machines which use the same binary type for double and
24 #include <math_private.h>
28 float __nexttowardf(float x
, long double y
)
30 float __nexttowardf(x
,y
)
39 EXTRACT_WORDS(hy
,ly
,y
);
40 ix
= hx
&0x7fffffff; /* |x| */
41 iy
= hy
&0x7fffffff; /* |y| */
43 if((ix
>0x7f800000) || /* x is nan */
44 ((iy
>=0x7ff00000)&&((iy
-0x7ff00000)|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
,(u_int32_t
)(hy
&0x80000000)|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(hy
<0||(ix
>>23)>(iy
>>20)-0x380
57 || ((ix
>>23)==(iy
>>20)-0x380
58 && (ix
&0x7fffff)>(((hy
<<3)|(ly
>>29))&0x7fffff))) /* x > y, x -= ulp */
60 else /* x < y, x += ulp */
63 if(hy
>=0||(ix
>>23)>(iy
>>20)-0x380
64 || ((ix
>>23)==(iy
>>20)-0x380
65 && (ix
&0x7fffff)>(((hy
<<3)|(ly
>>29))&0x7fffff))) /* x < y, x -= ulp */
67 else /* x > y, x += ulp */
72 x
= x
+x
; /* overflow */
73 if (FLT_EVAL_METHOD
!= 0)
74 /* Force conversion to float. */
79 float u
= x
*x
; /* underflow */
80 math_force_eval (u
); /* raise underflow flag */
85 weak_alias (__nexttowardf
, nexttowardf
)