Expand PMF_FN_* macros.
[netbsd-mini2440.git] / lib / libm / src / s_nextafterf.c
blob84acca4eeb59798cc105bf7a22dd6f2a33d5cfb1
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 #include <sys/cdefs.h>
17 #if defined(LIBM_SCCS) && !defined(lint)
18 __RCSID("$NetBSD: s_nextafterf.c,v 1.6 1999/07/02 15:37:43 simonb Exp $");
19 #endif
21 #include "math.h"
22 #include "math_private.h"
24 float
25 nextafterf(float x, float y)
27 int32_t hx,hy,ix,iy;
29 GET_FLOAT_WORD(hx,x);
30 GET_FLOAT_WORD(hy,y);
31 ix = hx&0x7fffffff; /* |x| */
32 iy = hy&0x7fffffff; /* |y| */
34 if((ix>0x7f800000) || /* x is nan */
35 (iy>0x7f800000)) /* y is nan */
36 return x+y;
37 if(x==y) return x; /* x=y, return x */
38 if(ix==0) { /* x == 0 */
39 SET_FLOAT_WORD(x,(hy&0x80000000)|1);/* return +-minsubnormal */
40 y = x*x;
41 if(y==x) return y; else return x; /* raise underflow flag */
43 if(hx>=0) { /* x > 0 */
44 if(hx>hy) { /* x > y, x -= ulp */
45 hx -= 1;
46 } else { /* x < y, x += ulp */
47 hx += 1;
49 } else { /* x < 0 */
50 if(hy>=0||hx>hy){ /* x < y, x -= ulp */
51 hx -= 1;
52 } else { /* x > y, x += ulp */
53 hx += 1;
56 hy = hx&0x7f800000;
57 if(hy>=0x7f800000) return x+x; /* overflow */
58 if(hy<0x00800000) { /* underflow */
59 y = x*x;
60 if(y!=x) { /* raise underflow flag */
61 SET_FLOAT_WORD(y,hx);
62 return y;
65 SET_FLOAT_WORD(x,hx);
66 return x;