Debian Codegraph @

mingw-w64-crt/math/x86/asinhf.c

raw
1 /**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the mingw-w64 runtime package.
4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5 */
6 #include <math.h>
7 #include <errno.h>
8 #include <float.h>
9 #include "fastmath.h"
10
11 /* asinh(x) = copysign(log(fabs(x) + sqrt(x * x + 1.0)), x) */
12 float asinhf(float x)
13 {
14 float z;
15 if (!isfinite (x))
16 return x;
17 z = fabsf (x);
18
19 /* Avoid setting FPU underflow exception flag in x * x. */
20 #if 0
21 if ( z < 0x1p-32)
22 return x;
23 #endif
24
25 /* See commentary in asinh */
26 const float asinhCutover = pow(2,FLT_MAX_EXP/2);
27
28 if (z < asinhCutover)
29 z = __fast_log1p (z + z * (z / (__fast_sqrt (z * z + 1.0) + 1.0)));
30 //z = __fast_log(z + __fast_sqrt(z * z + 1.0));
31 else
32 z = __fast_log(2) + __fast_log(z);
33 return copysignf(z, x); //ensure 0.0 -> 0.0 and -0.0 -> -0.0.
34 }