e_sinhf.c revision 226598
1251881Speter/* e_sinhf.c -- float version of e_sinh.c. 2251881Speter * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. 3251881Speter */ 4251881Speter 5251881Speter/* 6251881Speter * ==================================================== 7251881Speter * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 8251881Speter * 9251881Speter * Developed at SunPro, a Sun Microsystems, Inc. business. 10251881Speter * Permission to use, copy, modify, and distribute this 11251881Speter * software is freely granted, provided that this notice 12251881Speter * is preserved. 13251881Speter * ==================================================== 14251881Speter */ 15251881Speter 16251881Speter#include <sys/cdefs.h> 17251881Speter__FBSDID("$FreeBSD: head/lib/msun/src/e_sinhf.c 226598 2011-10-21 06:28:47Z das $"); 18251881Speter 19251881Speter#include "math.h" 20251881Speter#include "math_private.h" 21251881Speter 22251881Speterstatic const float one = 1.0, shuge = 1.0e37; 23251881Speter 24251881Speterfloat 25251881Speter__ieee754_sinhf(float x) 26251881Speter{ 27251881Speter float t,h; 28251881Speter int32_t ix,jx; 29251881Speter 30251881Speter GET_FLOAT_WORD(jx,x); 31251881Speter ix = jx&0x7fffffff; 32251881Speter 33251881Speter /* x is INF or NaN */ 34251881Speter if(ix>=0x7f800000) return x+x; 35251881Speter 36251881Speter h = 0.5; 37251881Speter if (jx<0) h = -h; 38251881Speter /* |x| in [0,9], return sign(x)*0.5*(E+E/(E+1))) */ 39251881Speter if (ix < 0x41100000) { /* |x|<9 */ 40251881Speter if (ix<0x39800000) /* |x|<2**-12 */ 41251881Speter if(shuge+x>one) return x;/* sinh(tiny) = tiny with inexact */ 42251881Speter t = expm1f(fabsf(x)); 43251881Speter if(ix<0x3f800000) return h*((float)2.0*t-t*t/(t+one)); 44251881Speter return h*(t+t/(t+one)); 45251881Speter } 46251881Speter 47251881Speter /* |x| in [9, logf(maxfloat)] return 0.5*exp(|x|) */ 48251881Speter if (ix < 0x42b17217) return h*__ieee754_expf(fabsf(x)); 49251881Speter 50251881Speter /* |x| in [logf(maxfloat), overflowthresold] */ 51251881Speter if (ix<=0x42b2d4fc) 52251881Speter return h*2.0F*__ldexp_expf(fabsf(x), -1); 53251881Speter 54251881Speter /* |x| > overflowthresold, sinh(x) overflow */ 55251881Speter return x*shuge; 56251881Speter} 57251881Speter