this repo has no description
1/*
2 * by Ian Ollmann
3 * Copyright � 2005, Apple Computer Inc. All rights reserved.
4 *
5 * based on MathLib v3
6 */
7
8#include <math.h>
9
10long double tanhl( long double x )
11{
12 static const long double overflow = 1.13565234062941445534588410310297337926799095235775e+04L / 2.0L; //log(0x1.0p16384)
13 long double fabsx = __builtin_fabsl( x );
14
15 if( x != x ) return x + x;
16
17 if( fabsx > 0x1.0p-32 ) //sqrt( negative epsilon )
18 {
19 if( fabsx < overflow )
20 {
21 fabsx = expm1l( -2.0L * fabsx );
22 fabsx = -fabsx / (2.0L + fabsx );
23 }
24 else
25 fabsx = 1.0L;
26 }
27 else
28 {
29 if( x == 0.0 )
30 return x;
31
32 fabsx *= 0x1.0p65;
33 fabsx -= 0x1.0p-16382L;
34 fabsx *= 0x1.0p-65;
35 }
36
37 if( x < 0 )
38 fabsx = -fabsx;
39
40 return fabsx;
41}