Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1906 serge 1
#include 
2
#include 
3
#include "fastmath.h"
4
 
5
/* acosh(x) = log (x + sqrt(x * x - 1)) */
6
float acoshf (float x)
7
{
8
  if (isnan (x))
9
    return x;
10
  if (x < 1.0f)
11
    {
12
      errno = EDOM;
13
      return nan("");
14
    }
15
 
16
 if (x > 0x1p32f)
17
    /*  Avoid overflow (and unnecessary calculation when
18
        sqrt (x * x - 1) == x). GCC optimizes by replacing
19
        the long double M_LN2 const with a fldln2 insn.  */
20
    return __fast_log (x) + 6.9314718055994530941723E-1L;
21
 
22
  /* Since  x >= 1, the arg to log will always be greater than
23
     the fyl2xp1 limit (approx 0.29) so just use logl. */
24
  return __fast_log (x + __fast_sqrt((x + 1.0) * (x - 1.0)));
25
}