POK
asinhf.c
1 /*
2  * POK header
3  *
4  * The following file is a part of the POK project. Any modification should
5  * made according to the POK licence. You CANNOT use this file or a part of
6  * this file is this part of a file for your own project
7  *
8  * For more information on the POK licence, please see our LICENCE FILE
9  *
10  * Please follow the coding guidelines described in doc/CODING_GUIDELINES
11  *
12  * Copyright (c) 2007-2009 POK team
13  *
14  * Created by julien on Fri Jan 30 14:41:34 2009
15  */
16 
17 /* s_asinhf.c -- float version of s_asinh.c.
18  * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
19  */
20 
21 /*
22  * ====================================================
23  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
24  *
25  * Developed at SunPro, a Sun Microsystems, Inc. business.
26  * Permission to use, copy, modify, and distribute this
27  * software is freely granted, provided that this notice
28  * is preserved.
29  * ====================================================
30  */
31 
32 #ifdef POK_NEEDS_LIBMATH
33 
34 #include <types.h>
35 #include <libm.h>
36 #include "math_private.h"
37 
38 static const float
39 one = 1.0000000000e+00, /* 0x3F800000 */
40 ln2 = 6.9314718246e-01, /* 0x3f317218 */
41 huge= 1.0000000000e+30;
42 
43 float
44 asinhf(float x)
45 {
46  float t,w;
47  int32_t hx,ix;
48  GET_FLOAT_WORD(hx,x);
49  ix = hx&0x7fffffff;
50  if(ix>=0x7f800000) return x+x; /* x is inf or NaN */
51  if(ix< 0x31800000) { /* |x|<2**-28 */
52  if(huge+x>one) return x; /* return x inexact except 0 */
53  }
54  if(ix>0x4d800000) { /* |x| > 2**28 */
55  w = __ieee754_logf(fabsf(x))+ln2;
56  } else if (ix>0x40000000) { /* 2**28 > |x| > 2.0 */
57  t = fabsf(x);
58  w = __ieee754_logf((float)2.0*t+one/(__ieee754_sqrtf(x*x+one)+t));
59  } else { /* 2.0 > |x| > 2**-28 */
60  t = x*x;
61  w =log1pf(fabsf(x)+t/(one+__ieee754_sqrtf(one+t)));
62  }
63  if(hx>0) return w; else return -w;
64 }
65 #endif
66