aboutsummaryrefslogtreecommitdiff
path: root/lib/msun/src/e_atanhl.c
diff options
context:
space:
mode:
authorDavid Schultz <das@FreeBSD.org>2013-06-10 06:04:58 +0000
committerDavid Schultz <das@FreeBSD.org>2013-06-10 06:04:58 +0000
commit998b640bcbca4ff197daf30fcff18d33889a7a0b (patch)
tree86fabb2acfe36058b468630da526ea699b62d9b8 /lib/msun/src/e_atanhl.c
parent7a62fe0f3eb250d49aafaca22d3789dff5acff9d (diff)
downloadsrc-998b640bcbca4ff197daf30fcff18d33889a7a0b.tar.gz
src-998b640bcbca4ff197daf30fcff18d33889a7a0b.zip
Add implementations of acoshl(), asinhl(), and atanhl(). This is a
merge of the work done by bde and myself.
Notes
Notes: svn path=/head/; revision=251599
Diffstat (limited to 'lib/msun/src/e_atanhl.c')
-rw-r--r--lib/msun/src/e_atanhl.c74
1 files changed, 74 insertions, 0 deletions
diff --git a/lib/msun/src/e_atanhl.c b/lib/msun/src/e_atanhl.c
new file mode 100644
index 000000000000..11d56ea52e7f
--- /dev/null
+++ b/lib/msun/src/e_atanhl.c
@@ -0,0 +1,74 @@
+/* from: FreeBSD: head/lib/msun/src/e_atanh.c 176451 2008-02-22 02:30:36Z das */
+
+/* @(#)e_atanh.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ *
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * See e_atanh.c for complete comments.
+ *
+ * Converted to long double by David Schultz <das@FreeBSD.ORG> and
+ * Bruce D. Evans.
+ */
+
+#include <float.h>
+#ifdef __i386__
+#include <ieeefp.h>
+#endif
+
+#include "fpmath.h"
+#include "math.h"
+#include "math_private.h"
+
+/* EXP_TINY is the threshold below which we use atanh(x) ~= x. */
+#if LDBL_MANT_DIG == 64
+#define EXP_TINY -34
+#elif LDBL_MANT_DIG == 113
+#define EXP_TINY -58
+#else
+#error "Unsupported long double format"
+#endif
+
+#if LDBL_MAX_EXP != 0x4000
+/* We also require the usual expsign encoding. */
+#error "Unsupported long double format"
+#endif
+
+#define BIAS (LDBL_MAX_EXP - 1)
+
+static const double one = 1.0, huge = 1e300;
+static const double zero = 0.0;
+
+long double
+atanhl(long double x)
+{
+ long double t;
+ uint16_t hx, ix;
+
+ ENTERI();
+ GET_LDBL_EXPSIGN(hx, x);
+ ix = hx & 0x7fff;
+ if (ix >= 0x3fff) /* |x| >= 1, or NaN or misnormal */
+ RETURNI(fabsl(x) == 1 ? x / zero : (x - x) / (x - x));
+ if (ix < BIAS + EXP_TINY && (huge + x) > zero)
+ RETURNI(x); /* x is tiny */
+ SET_LDBL_EXPSIGN(x, ix);
+ if (ix < 0x3ffe) { /* |x| < 0.5, or misnormal */
+ t = x+x;
+ t = 0.5*log1pl(t+t*x/(one-x));
+ } else
+ t = 0.5*log1pl((x+x)/(one-x));
+ RETURNI((hx & 0x8000) == 0 ? t : -t);
+}