1 /* s_nexttowardf.c -- float version of s_nextafter.c.
2 * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com
3 * and Jakub Jelinek, jj@ultra.linux.cz.
7 * ====================================================
8 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
10 * Developed at SunPro, a Sun Microsystems, Inc. business.
11 * Permission to use, copy, modify, and distribute this
12 * software is freely granted, provided that this notice
14 * ====================================================
17 #if defined(LIBM_SCCS) && !defined(lint)
18 static char rcsid
[] = "$NetBSD: $";
22 #include "math_private.h"
23 #include <math_ldbl_opt.h>
26 float __nexttowardf(float x
, long double y
)
28 float __nexttowardf(x
,y
)
38 GET_LDOUBLE_WORDS64(hy
,ly
,y
);
39 ix
= hx
&0x7fffffff; /* |x| */
40 iy
= hy
&0x7fffffffffffffffLL
; /* |y| */
41 uly
= ly
&0x7fffffffffffffffLL
; /* |y| */
43 if((ix
>0x7f800000) || /* x is nan */
44 ((iy
>=0x7ff0000000000000LL
)&&((iy
-0x7ff0000000000000LL
)|uly
)!=0))
47 if((long double) x
==y
) return y
; /* x=y, return y */
48 if(ix
==0) { /* x == 0 */
50 SET_FLOAT_WORD(x
,(u_int32_t
)((hy
>>32)&0x80000000)|1);/* return +-minsub*/
52 if(x2
==x
) return x2
; else return x
; /* raise underflow flag */
54 if(hx
>=0) { /* x > 0 */
55 if(hy
<0||(ix
>>23)>(iy
>>52)-0x380
56 || ((ix
>>23)==(iy
>>52)-0x380
57 && (ix
&0x7fffff)>((hy
>>29)&0x7fffff))) {/* x > y, x -= ulp */
59 } else { /* x < y, x += ulp */
63 if(hy
>=0||(ix
>>23)>(iy
>>52)-0x380
64 || ((ix
>>23)==(iy
>>52)-0x380
65 && (ix
&0x7fffff)>((hy
>>29)&0x7fffff))) {/* x < y, x -= ulp */
67 } else { /* x > y, x += ulp */
72 if(hy
>=0x7f800000) return x
+x
; /* overflow */
73 if(hy
<0x00800000) { /* underflow */
75 if(x2
!=x
) { /* raise underflow flag */
76 SET_FLOAT_WORD(x2
,hx
);
83 long_double_symbol (libm
, __nexttowardf
, nexttowardf
);