summaryrefslogtreecommitdiffstats
path: root/newlib/libm/common/s_log2.c
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2009-03-18 18:11:18 +0000
committerJeff Johnston <jjohnstn@redhat.com>2009-03-18 18:11:18 +0000
commitd57ff5a8acdd5653394aa6b3b688990f486d95d6 (patch)
tree7082101a893df4a65c0b6b6b7e2c15a808c5708f /newlib/libm/common/s_log2.c
parent2db87fe669aa7ff69ddffcea32b9cb38124ae480 (diff)
downloadcygnal-d57ff5a8acdd5653394aa6b3b688990f486d95d6.tar.gz
cygnal-d57ff5a8acdd5653394aa6b3b688990f486d95d6.tar.bz2
cygnal-d57ff5a8acdd5653394aa6b3b688990f486d95d6.zip
2009-03-18 Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
* libm/common/s_log2.c: New file. * libm/common/sf_log2.c: Ditto. * libm/common/Makefile.am: Add s_log2.c and sf_log2.c. * libm/common/Makefile.in: Regenerated. * libc/include/math.h: Add log2 and log2f function prototypes.
Diffstat (limited to 'newlib/libm/common/s_log2.c')
-rw-r--r--newlib/libm/common/s_log2.c73
1 files changed, 73 insertions, 0 deletions
diff --git a/newlib/libm/common/s_log2.c b/newlib/libm/common/s_log2.c
new file mode 100644
index 000000000..4683960eb
--- /dev/null
+++ b/newlib/libm/common/s_log2.c
@@ -0,0 +1,73 @@
+/* @(#)s_log2.c 5.1 93/09/24 */
+/* Modification from s_exp10.c Yaakov Selkowitz 2009. */
+
+/*
+ * ====================================================
+ * 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.
+ * ====================================================
+ */
+
+/*
+FUNCTION
+ <<log2>>, <<log2f>>---base 2 logarithm
+INDEX
+ log2
+INDEX
+ log2f
+
+ANSI_SYNOPSIS
+ #include <math.h>
+ double log2(double <[x]>);
+ float log2f(float <[x]>);
+
+TRAD_SYNOPSIS
+ #include <math.h>
+ double log2(<[x]>);
+ double <[x]>;
+
+ float log2f(<[x]>);
+ float <[x]>;
+
+DESCRIPTION
+ <<log2>> returns the base 2 logarithm of <[x]>.
+
+ <<log2f>> is identical, save that it takes and returns <<float>> values.
+
+RETURNS
+ On success, <<log2>> and <<log2f>> return the calculated value.
+ If the result underflows, the returned value is <<0>>. If the
+ result overflows, the returned value is <<HUGE_VAL>>. In
+ either case, <<errno>> is set to <<ERANGE>>.
+
+PORTABILITY
+ <<log2>> and <<log2f>> are required by ISO/IEC 9899:1999 and the
+ System V Interface Definition (Issue 6).
+*/
+
+/*
+ * wrapper log2(x)
+ */
+
+#include "fdlibm.h"
+#include <errno.h>
+#include <math.h>
+#undef log2
+
+#ifndef _DOUBLE_IS_32BITS
+
+#ifdef __STDC__
+ double log2(double x) /* wrapper log2 */
+#else
+ double log2(x) /* wrapper log2 */
+ double x;
+#endif
+{
+ return (log(x) / M_LOG2_E);
+}
+
+#endif /* defined(_DOUBLE_IS_32BITS) */