summaryrefslogtreecommitdiff
path: root/newlib/libm/mathfp/ef_acosh.c
diff options
context:
space:
mode:
authorPikalaxALT <pikalaxalt@gmail.com>2017-12-15 09:38:53 -0500
committerPikalaxALT <pikalaxalt@gmail.com>2017-12-15 09:39:34 -0500
commitf95a4a932476be2ba99e2fd081e8d2bc6ea12813 (patch)
tree75f67192cb2d7b7b575c94edda318e475239b63c /newlib/libm/mathfp/ef_acosh.c
parentf60aca96985e68c7d8a52eb7bc955fb80e132f73 (diff)
Import newlib and create makefile
Diffstat (limited to 'newlib/libm/mathfp/ef_acosh.c')
-rw-r--r--newlib/libm/mathfp/ef_acosh.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/newlib/libm/mathfp/ef_acosh.c b/newlib/libm/mathfp/ef_acosh.c
new file mode 100644
index 0000000..705be49
--- /dev/null
+++ b/newlib/libm/mathfp/ef_acosh.c
@@ -0,0 +1,53 @@
+/* ef_acosh.c -- float version of e_acosh.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ *
+ */
+
+#include "fdlibm.h"
+
+#ifdef __STDC__
+static const float
+#else
+static float
+#endif
+one = 1.0,
+ln2 = 6.9314718246e-01; /* 0x3f317218 */
+
+#ifdef __STDC__
+ float acoshf(float x)
+#else
+ float acoshf(x)
+ float x;
+#endif
+{
+ float t;
+ __int32_t hx;
+ GET_FLOAT_WORD(hx,x);
+ if(hx<0x3f800000) { /* x < 1 */
+ return (x-x)/(x-x);
+ } else if(hx >=0x4d800000) { /* x > 2**28 */
+ if(hx >=0x7f800000) { /* x is inf of NaN */
+ return x+x;
+ } else
+ return logf(x)+ln2; /* acosh(huge)=log(2x) */
+ } else if (hx==0x3f800000) {
+ return 0.0; /* acosh(1) = 0 */
+ } else if (hx > 0x40000000) { /* 2**28 > x > 2 */
+ t=x*x;
+ return logf((float)2.0*x-one/(x+sqrtf(t-one)));
+ } else { /* 1<x<2 */
+ t = x-one;
+ return log1pf(t+sqrtf((float)2.0*t+t*t));
+ }
+}