e_sinhf.c revision 97413
138032Speter/* e_sinhf.c -- float version of e_sinh.c.
238032Speter * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
3168515Sgshapiro */
464562Sgshapiro
538032Speter/*
638032Speter * ====================================================
738032Speter * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
838032Speter *
938032Speter * Developed at SunPro, a Sun Microsystems, Inc. business.
1038032Speter * Permission to use, copy, modify, and distribute this
1138032Speter * software is freely granted, provided that this notice
1238032Speter * is preserved.
13168515Sgshapiro * ====================================================
1438032Speter */
1538032Speter
1664562Sgshapiro#ifndef lint
1764562Sgshapirostatic char rcsid[] = "$FreeBSD: head/lib/msun/src/e_sinhf.c 97413 2002-05-28 18:15:04Z alfred $";
1890792Sgshapiro#endif
1990792Sgshapiro
20168515Sgshapiro#include "math.h"
2190792Sgshapiro#include "math_private.h"
2290792Sgshapiro
23168515Sgshapirostatic const float one = 1.0, shuge = 1.0e37;
24168515Sgshapiro
25168515Sgshapirofloat
26168515Sgshapiro__ieee754_sinhf(float x)
2790792Sgshapiro{
2890792Sgshapiro	float t,w,h;
2994334Sgshapiro	int32_t ix,jx;
3090792Sgshapiro
3194334Sgshapiro	GET_FLOAT_WORD(jx,x);
3294334Sgshapiro	ix = jx&0x7fffffff;
3394334Sgshapiro
3494334Sgshapiro    /* x is INF or NaN */
3590792Sgshapiro	if(ix>=0x7f800000) return x+x;
3694334Sgshapiro
3794334Sgshapiro	h = 0.5;
3894334Sgshapiro	if (jx<0) h = -h;
3994334Sgshapiro    /* |x| in [0,22], return sign(x)*0.5*(E+E/(E+1))) */
4094334Sgshapiro	if (ix < 0x41b00000) {		/* |x|<22 */
41132943Sgshapiro	    if (ix<0x31800000) 		/* |x|<2**-28 */
42132943Sgshapiro		if(shuge+x>one) return x;/* sinh(tiny) = tiny with inexact */
43132943Sgshapiro	    t = expm1f(fabsf(x));
4464562Sgshapiro	    if(ix<0x3f800000) return h*((float)2.0*t-t*t/(t+one));
4564562Sgshapiro	    return h*(t+t/(t+one));
4664562Sgshapiro	}
4790792Sgshapiro
48132943Sgshapiro    /* |x| in [22, log(maxdouble)] return 0.5*exp(|x|) */
4990792Sgshapiro	if (ix < 0x42b17180)  return h*__ieee754_expf(fabsf(x));
50
51    /* |x| in [log(maxdouble), overflowthresold] */
52	if (ix<=0x42b2d4fc) {
53	    w = __ieee754_expf((float)0.5*fabsf(x));
54	    t = h*w;
55	    return t*w;
56	}
57
58    /* |x| > overflowthresold, sinh(x) overflow */
59	return x*shuge;
60}
61