e_sinhf.c revision 152353
12116Sjkh/* e_sinhf.c -- float version of e_sinh.c.
22116Sjkh * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
32116Sjkh */
42116Sjkh
52116Sjkh/*
62116Sjkh * ====================================================
72116Sjkh * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
82116Sjkh *
92116Sjkh * Developed at SunPro, a Sun Microsystems, Inc. business.
102116Sjkh * Permission to use, copy, modify, and distribute this
118870Srgrimes * software is freely granted, provided that this notice
122116Sjkh * is preserved.
132116Sjkh * ====================================================
142116Sjkh */
152116Sjkh
162116Sjkh#ifndef lint
1750476Speterstatic char rcsid[] = "$FreeBSD: head/lib/msun/src/e_sinhf.c 152353 2005-11-13 00:41:46Z bde $";
182116Sjkh#endif
192116Sjkh
202116Sjkh#include "math.h"
212116Sjkh#include "math_private.h"
222116Sjkh
232116Sjkhstatic const float one = 1.0, shuge = 1.0e37;
242116Sjkh
2597413Salfredfloat
2697413Salfred__ieee754_sinhf(float x)
278870Srgrimes{
282116Sjkh	float t,w,h;
292116Sjkh	int32_t ix,jx;
302116Sjkh
312116Sjkh	GET_FLOAT_WORD(jx,x);
322116Sjkh	ix = jx&0x7fffffff;
332116Sjkh
342116Sjkh    /* x is INF or NaN */
358870Srgrimes	if(ix>=0x7f800000) return x+x;
362116Sjkh
372116Sjkh	h = 0.5;
382116Sjkh	if (jx<0) h = -h;
39152353Sbde    /* |x| in [0,9], return sign(x)*0.5*(E+E/(E+1))) */
40152353Sbde	if (ix < 0x41100000) {		/* |x|<9 */
41152353Sbde	    if (ix<0x39800000) 		/* |x|<2**-12 */
422116Sjkh		if(shuge+x>one) return x;/* sinh(tiny) = tiny with inexact */
432116Sjkh	    t = expm1f(fabsf(x));
442116Sjkh	    if(ix<0x3f800000) return h*((float)2.0*t-t*t/(t+one));
452116Sjkh	    return h*(t+t/(t+one));
462116Sjkh	}
472116Sjkh
48152353Sbde    /* |x| in [9, logf(maxfloat)] return 0.5*exp(|x|) */
49152353Sbde	if (ix < 0x42b17217)  return h*__ieee754_expf(fabsf(x));
502116Sjkh
51152353Sbde    /* |x| in [logf(maxfloat), overflowthresold] */
522116Sjkh	if (ix<=0x42b2d4fc) {
532116Sjkh	    w = __ieee754_expf((float)0.5*fabsf(x));
542116Sjkh	    t = h*w;
552116Sjkh	    return t*w;
562116Sjkh	}
572116Sjkh
582116Sjkh    /* |x| > overflowthresold, sinh(x) overflow */
592116Sjkh	return x*shuge;
602116Sjkh}
61