Blame sysdeps/ieee754/ldbl-96/s_asinhl.c

Packit 6c4009
/* s_asinhl.c -- long double version of s_asinh.c.
Packit 6c4009
 * Conversion to long double by Ulrich Drepper,
Packit 6c4009
 * Cygnus Support, drepper@cygnus.com.
Packit 6c4009
 */
Packit 6c4009
Packit 6c4009
/*
Packit 6c4009
 * ====================================================
Packit 6c4009
 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
Packit 6c4009
 *
Packit 6c4009
 * Developed at SunPro, a Sun Microsystems, Inc. business.
Packit 6c4009
 * Permission to use, copy, modify, and distribute this
Packit 6c4009
 * software is freely granted, provided that this notice
Packit 6c4009
 * is preserved.
Packit 6c4009
 * ====================================================
Packit 6c4009
 */
Packit 6c4009
Packit 6c4009
#if defined(LIBM_SCCS) && !defined(lint)
Packit 6c4009
static char rcsid[] = "$NetBSD: $";
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
/* asinhl(x)
Packit 6c4009
 * Method :
Packit 6c4009
 *	Based on
Packit 6c4009
 *		asinhl(x) = signl(x) * logl [ |x| + sqrtl(x*x+1) ]
Packit 6c4009
 *	we have
Packit 6c4009
 *	asinhl(x) := x  if  1+x*x=1,
Packit 6c4009
 *		  := signl(x)*(logl(x)+ln2)) for large |x|, else
Packit 6c4009
 *		  := signl(x)*logl(2|x|+1/(|x|+sqrtl(x*x+1))) if|x|>2, else
Packit 6c4009
 *		  := signl(x)*log1pl(|x| + x^2/(1 + sqrtl(1+x^2)))
Packit 6c4009
 */
Packit 6c4009
Packit 6c4009
#include <float.h>
Packit 6c4009
#include <math.h>
Packit 6c4009
#include <math_private.h>
Packit 6c4009
#include <math-underflow.h>
Packit 6c4009
#include <libm-alias-ldouble.h>
Packit 6c4009
Packit 6c4009
static const long double
Packit 6c4009
one =  1.000000000000000000000e+00L, /* 0x3FFF, 0x00000000, 0x00000000 */
Packit 6c4009
ln2 =  6.931471805599453094287e-01L, /* 0x3FFE, 0xB17217F7, 0xD1CF79AC */
Packit 6c4009
huge=  1.000000000000000000e+4900L;
Packit 6c4009
Packit 6c4009
long double __asinhl(long double x)
Packit 6c4009
{
Packit 6c4009
	long double t,w;
Packit 6c4009
	int32_t hx,ix;
Packit 6c4009
	GET_LDOUBLE_EXP(hx,x);
Packit 6c4009
	ix = hx&0x7fff;
Packit 6c4009
	if(__builtin_expect(ix< 0x3fde, 0)) {	/* |x|<2**-34 */
Packit 6c4009
	    math_check_force_underflow (x);
Packit 6c4009
	    if(huge+x>one) return x;	/* return x inexact except 0 */
Packit 6c4009
	}
Packit 6c4009
	if(__builtin_expect(ix>0x4020,0)) {		/* |x| > 2**34 */
Packit 6c4009
	    if(ix==0x7fff) return x+x;	/* x is inf or NaN */
Packit 6c4009
	    w = __ieee754_logl(fabsl(x))+ln2;
Packit 6c4009
	} else {
Packit 6c4009
	    long double xa = fabsl(x);
Packit 6c4009
	    if (ix>0x4000) {	/* 2**34 > |x| > 2.0 */
Packit 6c4009
		w = __ieee754_logl(2.0*xa+one/(sqrtl(xa*xa+one)+xa));
Packit 6c4009
	    } else {		/* 2.0 > |x| > 2**-28 */
Packit 6c4009
		t = xa*xa;
Packit 6c4009
		w =__log1pl(xa+t/(one+sqrtl(one+t)));
Packit 6c4009
	    }
Packit 6c4009
	}
Packit 6c4009
	return __copysignl(w, x);
Packit 6c4009
}
Packit 6c4009
libm_alias_ldouble (__asinh, asinh)