Blame sysdeps/ieee754/flt-32/e_sinhf.c

Packit 6c4009
/* e_sinhf.c -- float version of e_sinh.c.
Packit 6c4009
 * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@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
#include <float.h>
Packit 6c4009
#include <math.h>
Packit 6c4009
#include <math-narrow-eval.h>
Packit 6c4009
#include <math_private.h>
Packit 6c4009
#include <math-underflow.h>
Packit 6c4009
Packit 6c4009
static const float one = 1.0, shuge = 1.0e37;
Packit 6c4009
Packit 6c4009
float
Packit 6c4009
__ieee754_sinhf(float x)
Packit 6c4009
{
Packit 6c4009
	float t,w,h;
Packit 6c4009
	int32_t ix,jx;
Packit 6c4009
Packit 6c4009
	GET_FLOAT_WORD(jx,x);
Packit 6c4009
	ix = jx&0x7fffffff;
Packit 6c4009
Packit 6c4009
    /* x is INF or NaN */
Packit 6c4009
	if(__builtin_expect(ix>=0x7f800000, 0)) return x+x;
Packit 6c4009
Packit 6c4009
	h = 0.5;
Packit 6c4009
	if (jx<0) h = -h;
Packit 6c4009
    /* |x| in [0,22], return sign(x)*0.5*(E+E/(E+1))) */
Packit 6c4009
	if (ix < 0x41b00000) {		/* |x|<22 */
Packit 6c4009
	    if (__builtin_expect(ix<0x31800000, 0)) {	/* |x|<2**-28 */
Packit 6c4009
		math_check_force_underflow (x);
Packit 6c4009
		if(shuge+x>one) return x;/* sinh(tiny) = tiny with inexact */
Packit 6c4009
	    }
Packit 6c4009
	    t = __expm1f(fabsf(x));
Packit 6c4009
	    if(ix<0x3f800000) return h*((float)2.0*t-t*t/(t+one));
Packit 6c4009
	    return h*(t+t/(t+one));
Packit 6c4009
	}
Packit 6c4009
Packit 6c4009
    /* |x| in [22, log(maxdouble)] return 0.5*exp(|x|) */
Packit 6c4009
	if (ix < 0x42b17180)  return h*__ieee754_expf(fabsf(x));
Packit 6c4009
Packit 6c4009
    /* |x| in [log(maxdouble), overflowthresold] */
Packit 6c4009
	if (ix<=0x42b2d4fc) {
Packit 6c4009
	    w = __ieee754_expf((float)0.5*fabsf(x));
Packit 6c4009
	    t = h*w;
Packit 6c4009
	    return t*w;
Packit 6c4009
	}
Packit 6c4009
Packit 6c4009
    /* |x| > overflowthresold, sinh(x) overflow */
Packit 6c4009
	return math_narrow_eval (x*shuge);
Packit 6c4009
}
Packit 6c4009
strong_alias (__ieee754_sinhf, __sinhf_finite)