Mercurial > mxe-octave
diff src/build-msvctools/math/acosh.c @ 3061:f8299bb6c872
Initial support for native MSVC compilation.
* add MSVC support files: compiler wrappers and support libraries
* adapt libiconv to work with MSVC
* adapt gettext to work with MSVC
author | Michael Goffioul <michael.goffioul@gmail.com> |
---|---|
date | Mon, 17 Jun 2013 22:43:11 -0400 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/acosh.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,26 @@ +#include <math.h> +#include <errno.h> +#include "fastmath.h" + +/* acosh(x) = log (x + sqrt(x * x - 1)) */ +double acosh (double x) +{ + if (isnan (x)) + return x; + + if (x < 1.0) + { + errno = EDOM; + return nan(""); + } + + if (x > 0x1p32) + /* Avoid overflow (and unnecessary calculation when + sqrt (x * x - 1) == x). GCC optimizes by replacing + the long double M_LN2 const with a fldln2 insn. */ + return __fast_log (x) + 6.9314718055994530941723E-1L; + + /* Since x >= 1, the arg to log will always be greater than + the fyl2xp1 limit (approx 0.29) so just use logl. */ + return __fast_log (x + __fast_sqrt((x + 1.0) * (x - 1.0))); +}