1 /* sf_nextafter.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 * ====================================================
19 float nextafterf(float x
, float y
)
25 __int32_t hx
,hy
,ix
,iy
;
29 ix
= hx
&0x7fffffff; /* |x| */
30 iy
= hy
&0x7fffffff; /* |y| */
32 if(FLT_UWORD_IS_NAN(ix
) ||
35 if(x
==y
) return x
; /* x=y, return x */
36 if(FLT_UWORD_IS_ZERO(ix
)) { /* x == 0 */
37 SET_FLOAT_WORD(x
,(hy
&0x80000000)|FLT_UWORD_MIN
);
39 if(y
==x
) return y
; else return x
; /* raise underflow flag */
41 if(hx
>=0) { /* x > 0 */
42 if(hx
>hy
) { /* x > y, x -= ulp */
44 } else { /* x < y, x += ulp */
48 if(hy
>=0||hx
>hy
){ /* x < y, x -= ulp */
50 } else { /* x > y, x += ulp */
55 if(hy
>FLT_UWORD_MAX
) return x
+x
; /* overflow */
56 if(hy
<0x00800000) { /* underflow */
58 if(y
!=x
) { /* raise underflow flag */
67 #ifdef _DOUBLE_IS_32BITS
70 double nextafter(double x
, double y
)
76 return (double) nextafterf((float) x
, (float) x
);
79 #endif /* defined(_DOUBLE_IS_32BITS) */