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
25 #include <math-barriers.h>
26 #include <math_private.h>
29 float __nexttowardf(float x
, long double y
)
35 EXTRACT_WORDS(hy
,ly
,y
);
36 ix
= hx
&0x7fffffff; /* |x| */
37 iy
= hy
&0x7fffffff; /* |y| */
39 if((ix
>0x7f800000) || /* x is nan */
40 ((iy
>=0x7ff00000)&&((iy
-0x7ff00000)|ly
)!=0)) /* y is nan */
42 if((long double) x
==y
) return y
; /* x=y, return y */
43 if(ix
==0) { /* x == 0 */
45 SET_FLOAT_WORD(x
,(uint32_t)(hy
&0x80000000)|1);/* return +-minsub*/
46 u
= math_opt_barrier (x
);
48 math_force_eval (u
); /* raise underflow flag */
51 if(hx
>=0) { /* x > 0 */
52 if(x
> y
) /* x -= ulp */
54 else /* x < y, x += ulp */
57 if(x
< y
) /* x -= ulp */
59 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
)