1 /* $NetBSD: s_nexttowardf.c,v 1.3 2013/02/09 23:14:44 christos Exp $ */
4 * ====================================================
5 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
7 * Developed at SunPro, a Sun Microsystems, Inc. business.
8 * Permission to use, copy, modify, and distribute this
9 * software is freely granted, provided that this notice
11 * ====================================================
14 #include <sys/cdefs.h>
16 __FBSDID("$FreeBSD: src/lib/msun/src/s_nexttowardf.c,v 1.3 2011/02/10 07:38:38 das Exp $");
18 __RCSID("$NetBSD: s_nexttowardf.c,v 1.3 2013/02/09 23:14:44 christos Exp $");
23 #include <machine/ieee.h>
26 #include "math_private.h"
30 nexttowardf(float x
, long double y
)
37 ix
= hx
&0x7fffffff; /* |x| */
39 memset(&uy
, 0, sizeof(uy
));
41 uy
.extu_ext
.ext_frach
&= ~0x80000000;
44 (uy
.extu_ext
.ext_exp
== EXT_EXP_INFNAN
&&
45 (uy
.extu_ext
.ext_frach
| uy
.extu_ext
.ext_fracl
) != 0))
46 return x
+y
; /* x or y is nan */
47 if(x
==y
) return (float)y
; /* x=y, return y */
48 if(ix
==0) { /* x == 0 */
49 SET_FLOAT_WORD(x
,(uy
.extu_ext
.ext_sign
<<31)|1);/* return +-minsubnormal */
51 if(t
==x
) return t
; else return x
; /* raise underflow flag */
53 if((hx
>= 0) ^ (x
< y
)) /* x -= ulp */
58 if(ix
>=0x7f800000) return x
+x
; /* overflow */
59 if(ix
<0x00800000) { /* underflow */
61 if(t
!=x
) { /* raise underflow flag */