libs/libm/src/s_nextafterl.c
/*
 * IEEE functions
 *      nextafterl(x,y)
 *      return the next machine floating-point number of x in the
 *      direction toward y.
 *   Special cases:
 *	If x == y, y shall be returned
 *	If x or y is NaN, a NaN shall be returned
 */
IEEE functions
nextafterl(x,y)
return the next machine floating-point number of x in the
direction toward y.
Special cases:
If x == y, y shall be returned
If x or y is NaN, a NaN shall be returned
IEEE functions nextafterl ( x y ) return the next machine floating - point number of x in the direction toward y . Special cases : If x == y y shall be returned If x or y is NaN a NaN shall be returned
long double
nextafterl(long double x, long double y)
{
	volatile long double t;
	union ieee_ext_u ux, uy;
	ux.extu_ld = x;
	uy.extu_ld = y;
	if ((ux.extu_exp == EXT_EXP_NAN &&
		((ux.extu_frach &~ LDBL_NBIT)|ux.extu_fracl) != 0) ||
	    (uy.extu_exp == EXT_EXP_NAN &&
		((uy.extu_frach &~ LDBL_NBIT)|uy.extu_fracl) != 0))
		return x+y;			
	if (x == y) return y;			
	if (x == 0.0) {
		ux.extu_frach = 0;		
		ux.extu_fracl = 1;
		ux.extu_sign = uy.extu_sign;
		t = ux.extu_ld * ux.extu_ld;
		if (t == ux.extu_ld)
			return t;
		else
			return ux.extu_ld;	
	}
	if ((x>0.0) ^ (x<y)) {			
		if (ux.extu_fracl == 0) {
			if ((ux.extu_frach & ~LDBL_NBIT) == 0)
				ux.extu_exp -= 1;
			ux.extu_frach = (ux.extu_frach - 1) |
					(ux.extu_frach & LDBL_NBIT);
		}
		ux.extu_fracl -= 1;
	} else {				
		ux.extu_fracl += 1;
		if (ux.extu_fracl == 0) {
			ux.extu_frach = (ux.extu_frach + 1) |
					(ux.extu_frach & LDBL_NBIT);
			if ((ux.extu_frach & ~LDBL_NBIT) == 0)
				ux.extu_exp += 1;
		}
	}
	if (ux.extu_exp == EXT_EXP_INF)
		return x+x;			
	if (ux.extu_exp == 0) {			
		mask_nbit_l(ux);
		t = ux.extu_ld * ux.extu_ld;
		if (t != ux.extu_ld)		
			return ux.extu_ld;
	}
	return ux.extu_ld;
}
long double nextafterl ( long double x , long double y ) { volatile long double t ; union ieee_ext_u ux , uy ; ux . extu_ld = x ; uy . extu_ld = y ; if ( ( ux . extu_exp == EXT_EXP_NAN && ( ( ux . extu_frach & ~ LDBL_NBIT ) | ux . extu_fracl ) != 0 ) || ( uy . extu_exp == EXT_EXP_NAN && ( ( uy . extu_frach & ~ LDBL_NBIT ) | uy . extu_fracl ) != 0 ) ) return x + y ; if ( x == y ) return y ; if ( x == 0.0 ) { ux . extu_frach = 0 ; ux . extu_fracl = 1 ; ux . extu_sign = uy . extu_sign ; t = ux . extu_ld * ux . extu_ld ; if ( t == ux . extu_ld ) return t ; else return ux . extu_ld ; } if ( ( x > 0.0 ) ^ ( x < y ) ) { if ( ux . extu_fracl == 0 ) { if ( ( ux . extu_frach & ~ LDBL_NBIT ) == 0 ) ux . extu_exp -= 1 ; ux . extu_frach = ( ux . extu_frach - 1 ) | ( ux . extu_frach & LDBL_NBIT ) ; } ux . extu_fracl -= 1 ; } else { ux . extu_fracl += 1 ; if ( ux . extu_fracl == 0 ) { ux . extu_frach = ( ux . extu_frach + 1 ) | ( ux . extu_frach & LDBL_NBIT ) ; if ( ( ux . extu_frach & ~ LDBL_NBIT ) == 0 ) ux . extu_exp += 1 ; } } if ( ux . extu_exp == EXT_EXP_INF ) return x + x ; if ( ux . extu_exp == 0 ) { mask_nbit_l ( ux ) ; t = ux . extu_ld * ux . extu_ld ; if ( t != ux . extu_ld ) return ux . extu_ld ; } return ux . extu_ld ; }
IEEE functions
      nextafterl(x,y)
      return the next machine floating-point number of x in the
      direction toward y.
IEEE functions nextafterl ( x y ) return the next machine floating - point number of x in the direction toward y .
/* x or y is nan */ /* x=y, return y */ /* return +-minsubnormal */ /* raise underflow flag */ /* x -= ulp */ /* x += ulp */ /* overflow  */ /* underflow */ /* raise underflow flag */