Fix Wundef warning for __STDC_VERSION__
[glibc.git] / sysdeps / ieee754 / flt-32 / s_nextafterf.c
blob22e0b3d4ed4231a3f2c2226b7fdab1a5b74a5c7f
1 /* s_nextafterf.c -- float version of s_nextafter.c.
2 * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
3 */
5 /*
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
12 * is preserved.
13 * ====================================================
16 #if defined(LIBM_SCCS) && !defined(lint)
17 static char rcsid[] = "$NetBSD: s_nextafterf.c,v 1.4 1995/05/10 20:48:01 jtc Exp $";
18 #endif
20 #include <math.h>
21 #include <math_private.h>
22 #include <float.h>
24 float __nextafterf(float x, float y)
26 int32_t hx,hy,ix,iy;
28 GET_FLOAT_WORD(hx,x);
29 GET_FLOAT_WORD(hy,y);
30 ix = hx&0x7fffffff; /* |x| */
31 iy = hy&0x7fffffff; /* |y| */
33 if((ix>0x7f800000) || /* x is nan */
34 (iy>0x7f800000)) /* y is nan */
35 return x+y;
36 if(x==y) return y; /* x=y, return y */
37 if(ix==0) { /* x == 0 */
38 float u;
39 SET_FLOAT_WORD(x,(hy&0x80000000)|1);/* return +-minsubnormal */
40 u = math_opt_barrier (x);
41 u = u*u;
42 math_force_eval (u); /* raise underflow flag */
43 return x;
45 if(hx>=0) { /* x > 0 */
46 if(hx>hy) { /* x > y, x -= ulp */
47 hx -= 1;
48 } else { /* x < y, x += ulp */
49 hx += 1;
51 } else { /* x < 0 */
52 if(hy>=0||hx>hy){ /* x < y, x -= ulp */
53 hx -= 1;
54 } else { /* x > y, x += ulp */
55 hx += 1;
58 hy = hx&0x7f800000;
59 if(hy>=0x7f800000) {
60 float u = x+x; /* overflow */
61 math_force_eval (u);
63 if(hy<0x00800000) {
64 float u = x*x; /* underflow */
65 math_force_eval (u); /* raise underflow flag */
67 SET_FLOAT_WORD(x,hx);
68 return x;
70 weak_alias (__nextafterf, nextafterf)