aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_math.c
diff options
context:
space:
mode:
authorOlivier Girondel <[email protected]>2015-01-04 04:40:55 +0100
committerMarcus Arendt <[email protected]>2015-01-14 15:58:51 +0100
commitfdf09e81de5e7f1ecfe71f98b56c411073badae8 (patch)
treed6a46aeb887b2b829a01889ed364d943b7ed7536 /erts/emulator/beam/erl_math.c
parent821d84c5860a9a26185efa19be407796422e3090 (diff)
downloadotp-fdf09e81de5e7f1ecfe71f98b56c411073badae8.tar.gz
otp-fdf09e81de5e7f1ecfe71f98b56c411073badae8.tar.bz2
otp-fdf09e81de5e7f1ecfe71f98b56c411073badae8.zip
Add math:log2/1
Diffstat (limited to 'erts/emulator/beam/erl_math.c')
-rw-r--r--erts/emulator/beam/erl_math.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/erts/emulator/beam/erl_math.c b/erts/emulator/beam/erl_math.c
index 16d4fdc09c..9b864628db 100644
--- a/erts/emulator/beam/erl_math.c
+++ b/erts/emulator/beam/erl_math.c
@@ -207,6 +207,24 @@ BIF_RETTYPE math_log_1(BIF_ALIST_1)
return math_call_1(BIF_P, log, BIF_ARG_1);
}
+#ifdef HAVE_LOG2
+static double
+log2_wrapper(double x)
+{
+ return log2(x);
+}
+#else
+static double
+log2_wrapper(double x)
+{
+ return log(x) / 0.6931471805599453; /* log(2.0); */
+}
+#endif
+
+BIF_RETTYPE math_log2_1(BIF_ALIST_1)
+{
+ return math_call_1(BIF_P, log2_wrapper, BIF_ARG_1);
+}
BIF_RETTYPE math_log10_1(BIF_ALIST_1)
{