1 /* s_nextafterf.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 * ====================================================
17 static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_nextafterf.c,v 1.5 1999/08/28 00:06:54 peter Exp $";
21 #include "math_private.h"
24 float nextafterf(float x, float y)
34 ix = hx&0x7fffffff; /* |x| */
35 iy = hy&0x7fffffff; /* |y| */
37 if((ix>0x7f800000) || /* x is nan */
38 (iy>0x7f800000)) /* y is nan */
40 if(x==y) return x; /* x=y, return x */
41 if(ix==0) { /* x == 0 */
42 SET_FLOAT_WORD(x,(hy&0x80000000)|1);/* return +-minsubnormal */
44 if(y==x) return y; else return x; /* raise underflow flag */
46 if(hx>=0) { /* x > 0 */
47 if(hx>hy) { /* x > y, x -= ulp */
49 } else { /* x < y, x += ulp */
53 if(hy>=0||hx>hy){ /* x < y, x -= ulp */
55 } else { /* x > y, x += ulp */
60 if(hy>=0x7f800000) return x+x; /* overflow */
61 if(hy<0x00800000) { /* underflow */
63 if(y!=x) { /* raise underflow flag */