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
* ====================================================
13
static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_nexttowardf.c,v 1.1 2005/03/07 04:57:38 das Exp $";
20
#include "math_private.h"
22
#define LDBL_INFNAN_EXP (LDBL_MAX_EXP * 2 - 1)
25
nexttowardf(float x, long double y)
32
ix = hx&0x7fffffff; /* |x| */
36
(uy.bits.exp == LDBL_INFNAN_EXP &&
37
((uy.bits.manh&~LDBL_NBIT)|uy.bits.manl) != 0))
38
return x+y; /* x or y is nan */
39
if(x==y) return (float)y; /* x=y, return y */
40
if(ix==0) { /* x == 0 */
41
SET_FLOAT_WORD(x,(uy.bits.sign<<31)|1);/* return +-minsubnormal */
43
if(t==x) return t; else return x; /* raise underflow flag */
45
if(hx>=0 ^ x < y) /* x -= ulp */
50
if(ix>=0x7f800000) return x+x; /* overflow */
51
if(ix<0x00800000) { /* underflow */
53
if(t!=x) { /* raise underflow flag */