e_sinhf.c revision 2116
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
112116Sjkh * software is freely granted, provided that this notice
122116Sjkh * is preserved.
132116Sjkh * ====================================================
142116Sjkh */
152116Sjkh
162116Sjkh#ifndef lint
172116Sjkhstatic char rcsid[] = "$Id: e_sinhf.c,v 1.2 1994/08/18 23:06:04 jtc Exp $";
182116Sjkh#endif
192116Sjkh
202116Sjkh#include "math.h"
212116Sjkh#include "math_private.h"
222116Sjkh
232116Sjkh#ifdef __STDC__
242116Sjkhstatic const float one = 1.0, shuge = 1.0e37;
252116Sjkh#else
262116Sjkhstatic float one = 1.0, shuge = 1.0e37;
272116Sjkh#endif
282116Sjkh
292116Sjkh#ifdef __STDC__
302116Sjkh	float __ieee754_sinhf(float x)
312116Sjkh#else
322116Sjkh	float __ieee754_sinhf(x)
332116Sjkh	float x;
342116Sjkh#endif
352116Sjkh{
362116Sjkh	float t,w,h;
372116Sjkh	int32_t ix,jx;
382116Sjkh
392116Sjkh	GET_FLOAT_WORD(jx,x);
402116Sjkh	ix = jx&0x7fffffff;
412116Sjkh
422116Sjkh    /* x is INF or NaN */
432116Sjkh	if(ix>=0x7f800000) return x+x;
442116Sjkh
452116Sjkh	h = 0.5;
462116Sjkh	if (jx<0) h = -h;
472116Sjkh    /* |x| in [0,22], return sign(x)*0.5*(E+E/(E+1))) */
482116Sjkh	if (ix < 0x41b00000) {		/* |x|<22 */
492116Sjkh	    if (ix<0x31800000) 		/* |x|<2**-28 */
502116Sjkh		if(shuge+x>one) return x;/* sinh(tiny) = tiny with inexact */
512116Sjkh	    t = expm1f(fabsf(x));
522116Sjkh	    if(ix<0x3f800000) return h*((float)2.0*t-t*t/(t+one));
532116Sjkh	    return h*(t+t/(t+one));
542116Sjkh	}
552116Sjkh
562116Sjkh    /* |x| in [22, log(maxdouble)] return 0.5*exp(|x|) */
572116Sjkh	if (ix < 0x42b17180)  return h*__ieee754_expf(fabsf(x));
582116Sjkh
592116Sjkh    /* |x| in [log(maxdouble), overflowthresold] */
602116Sjkh	if (ix<=0x42b2d4fc) {
612116Sjkh	    w = __ieee754_expf((float)0.5*fabsf(x));
622116Sjkh	    t = h*w;
632116Sjkh	    return t*w;
642116Sjkh	}
652116Sjkh
662116Sjkh    /* |x| > overflowthresold, sinh(x) overflow */
672116Sjkh	return x*shuge;
682116Sjkh}
69