1 /* origin: FreeBSD /usr/src/lib/msun/src/s_nexttoward.c */
3 * ====================================================
4 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
6 * Developed at SunPro, a Sun Microsystems, Inc. business.
7 * Permission to use, copy, modify, and distribute this
8 * software is freely granted, provided that this notice
10 * ====================================================
15 double nexttoward(double x, long double y)
17 return nextafter(x, y);
20 double nexttoward(double x, long double y)
27 EXTRACT_WORDS(hx, lx, x);
31 if ((ix >= 0x7ff00000 && ((ix-0x7ff00000)|lx) != 0) ||
32 (uy.bits.exp == 0x7fff && ((uy.bits.manh&~LDBL_NBIT)|uy.bits.manl) != 0))
33 return x + y; /* x or y is nan */
37 INSERT_WORDS(x, uy.bits.sign<<31, 1); /* return +-minsubnormal */
44 if (hx > 0.0 ^ x < y) { /* x -= ulp */
48 } else { /* x += ulp */
54 if (ix >= 0x7ff00000) /* overflow */
56 if (ix < 0x00100000) { /* underflow */
57 /* raise underflow flag */
60 INSERT_WORDS(x, hx, lx);
64 INSERT_WORDS(x, hx, lx);