2 * ====================================================
3 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
5 * Developed at SunPro, a Sun Microsystems, Inc. business.
6 * Permission to use, copy, modify, and distribute this
7 * software is freely granted, provided that this notice
9 * ====================================================
12 #include <sys/cdefs.h>
17 #include "math_private.h"
19 #define LDBL_INFNAN_EXP (LDBL_MAX_EXP * 2 - 1)
22 nexttowardf(float x, long double y)
29 ix = hx&0x7fffffff; /* |x| */
33 (uy.bits.exp == LDBL_INFNAN_EXP &&
34 ((uy.bits.manh&~LDBL_NBIT)|uy.bits.manl) != 0))
35 return x+y; /* x or y is nan */
36 if(x==y) return (float)y; /* x=y, return y */
37 if(ix==0) { /* x == 0 */
38 SET_FLOAT_WORD(x,(uy.bits.sign<<31)|1);/* return +-minsubnormal */
40 if(t==x) return t; else return x; /* raise underflow flag */
42 if(hx>=0 ^ x < y) /* x -= ulp */
47 if(ix>=0x7f800000) return x+x; /* overflow */
48 if(ix<0x00800000) { /* underflow */
50 if(t!=x) { /* raise underflow flag */