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
)
26 float __nexttowardf(x
,y
)
35 GET_LDOUBLE_WORDS(esy
,hy
,ly
,y
);
36 ix
= hx
&0x7fffffff; /* |x| */
37 iy
= esy
&0x7fff; /* |y| */
39 if((ix
>0x7f800000) || /* x is nan */
40 (iy
>=0x7fff&&((hy
|ly
)|-(hy
|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
,(esy
&0x8000?0x80000000:0)|1);/* return +-minsub*/
47 if(x2
==x
) return x2
; else return x
; /* raise underflow flag */
49 if(hx
>=0) { /* x > 0 */
50 if(esy
>=0x8000||((ix
>>23)&0xff)>iy
51 || (((ix
>>23)&0xff)==iy
52 && ((ix
&0x7fffff)<<8)>(hy
&0x7fffffff))) {/* x > y, x -= ulp */
54 } else { /* x < y, x += ulp */
58 if(esy
<0x8000||((ix
>>23)&0xff)>iy
59 || (((ix
>>23)&0xff)==iy
60 && ((ix
&0x7fffff)<<8)>(hy
&0x7fffffff))) {/* x < y, x -= ulp */
62 } else { /* x > y, x += ulp */
67 if(hy
>=0x7f800000) return x
+x
; /* overflow */
68 if(hy
<0x00800000) { /* underflow */
70 if(x2
!=x
) { /* raise underflow flag */
71 SET_FLOAT_WORD(x2
,hx
);
78 weak_alias (__nexttowardf
, nexttowardf
)