Back to index

glibc  2.9
e_sinhf.c
Go to the documentation of this file.
00001 /* e_sinhf.c -- float version of e_sinh.c.
00002  * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
00003  */
00004 
00005 /*
00006  * ====================================================
00007  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
00008  *
00009  * Developed at SunPro, a Sun Microsystems, Inc. business.
00010  * Permission to use, copy, modify, and distribute this
00011  * software is freely granted, provided that this notice 
00012  * is preserved.
00013  * ====================================================
00014  */
00015 
00016 #if defined(LIBM_SCCS) && !defined(lint)
00017 static char rcsid[] = "$NetBSD: e_sinhf.c,v 1.4 1995/05/10 20:46:15 jtc Exp $";
00018 #endif
00019 
00020 #include "math.h"
00021 #include "math_private.h"
00022 
00023 #ifdef __STDC__
00024 static const float one = 1.0, shuge = 1.0e37;
00025 #else
00026 static float one = 1.0, shuge = 1.0e37;
00027 #endif
00028 
00029 #ifdef __STDC__
00030        float __ieee754_sinhf(float x)
00031 #else
00032        float __ieee754_sinhf(x)
00033        float x;
00034 #endif
00035 {      
00036        float t,w,h;
00037        int32_t ix,jx;
00038 
00039        GET_FLOAT_WORD(jx,x);
00040        ix = jx&0x7fffffff;
00041 
00042     /* x is INF or NaN */
00043        if(ix>=0x7f800000) return x+x;     
00044 
00045        h = 0.5;
00046        if (jx<0) h = -h;
00047     /* |x| in [0,22], return sign(x)*0.5*(E+E/(E+1))) */
00048        if (ix < 0x41b00000) {             /* |x|<22 */
00049            if (ix<0x31800000)             /* |x|<2**-28 */
00050               if(shuge+x>one) return x;/* sinh(tiny) = tiny with inexact */
00051            t = __expm1f(fabsf(x));
00052            if(ix<0x3f800000) return h*((float)2.0*t-t*t/(t+one));
00053            return h*(t+t/(t+one));
00054        }
00055 
00056     /* |x| in [22, log(maxdouble)] return 0.5*exp(|x|) */
00057        if (ix < 0x42b17180)  return h*__ieee754_expf(fabsf(x));
00058 
00059     /* |x| in [log(maxdouble), overflowthresold] */
00060        if (ix<=0x42b2d4fc) {
00061            w = __ieee754_expf((float)0.5*fabsf(x));
00062            t = h*w;
00063            return t*w;
00064        }
00065 
00066     /* |x| > overflowthresold, sinh(x) overflow */
00067        return x*shuge;
00068 }