e_sinhf.c revision 226598
1146773Ssam/* e_sinhf.c -- float version of e_sinh.c. 2146773Ssam * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. 3146773Ssam */ 4146773Ssam 5146773Ssam/* 6146773Ssam * ==================================================== 7146773Ssam * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 8146773Ssam * 9146773Ssam * Developed at SunPro, a Sun Microsystems, Inc. business. 10146773Ssam * Permission to use, copy, modify, and distribute this 11146773Ssam * software is freely granted, provided that this notice 12146773Ssam * is preserved. 13146773Ssam * ==================================================== 14146773Ssam */ 15146773Ssam 16146773Ssam#include <sys/cdefs.h> 17146773Ssam__FBSDID("$FreeBSD: head/lib/msun/src/e_sinhf.c 226598 2011-10-21 06:28:47Z das $"); 18146773Ssam 19146773Ssam#include "math.h" 20146773Ssam#include "math_private.h" 21146773Ssam 22146773Ssamstatic const float one = 1.0, shuge = 1.0e37; 23162017Ssam 24146773Ssamfloat 25146773Ssam__ieee754_sinhf(float x) 26146773Ssam{ 27146773Ssam float t,h; 28146773Ssam int32_t ix,jx; 29146773Ssam 30146773Ssam GET_FLOAT_WORD(jx,x); 31146773Ssam ix = jx&0x7fffffff; 32146773Ssam 33146773Ssam /* x is INF or NaN */ 34146773Ssam if(ix>=0x7f800000) return x+x; 35146773Ssam 36146773Ssam h = 0.5; 37146773Ssam if (jx<0) h = -h; 38146773Ssam /* |x| in [0,9], return sign(x)*0.5*(E+E/(E+1))) */ 39146773Ssam if (ix < 0x41100000) { /* |x|<9 */ 40146773Ssam if (ix<0x39800000) /* |x|<2**-12 */ 41146773Ssam if(shuge+x>one) return x;/* sinh(tiny) = tiny with inexact */ 42146773Ssam t = expm1f(fabsf(x)); 43146773Ssam if(ix<0x3f800000) return h*((float)2.0*t-t*t/(t+one)); 44146773Ssam return h*(t+t/(t+one)); 45146773Ssam } 46146773Ssam 47146773Ssam /* |x| in [9, logf(maxfloat)] return 0.5*exp(|x|) */ 48146773Ssam if (ix < 0x42b17217) return h*__ieee754_expf(fabsf(x)); 49146773Ssam 50146773Ssam /* |x| in [logf(maxfloat), overflowthresold] */ 51146773Ssam if (ix<=0x42b2d4fc) 52146773Ssam return h*2.0F*__ldexp_expf(fabsf(x), -1); 53146773Ssam 54146773Ssam /* |x| > overflowthresold, sinh(x) overflow */ 55146773Ssam return x*shuge; 56146773Ssam} 57146773Ssam