aboutsummaryrefslogtreecommitdiff
path: root/py/modmath.c
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2015-11-13 13:24:39 +0200
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2015-11-13 15:24:48 +0200
commit6d1eabfeaa44cab32a6ea37d3c041a9b06ac5798 (patch)
treeca4bd99d9855abb28359d599c9a8d96bf7693586 /py/modmath.c
parent432e8275a9b383ba7f33b4a582d6dde0e1a1e35d (diff)
unix/mpconfigport: Move log2() definition to modmath.c.
It's safer to define it where it's used, defining it for all source files may lead to hard to diagnose conflicts in corner cases.
Diffstat (limited to 'py/modmath.c')
-rw-r--r--py/modmath.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/py/modmath.c b/py/modmath.c
index ec74e974e..48ba47058 100644
--- a/py/modmath.c
+++ b/py/modmath.c
@@ -52,6 +52,11 @@
STATIC mp_obj_t mp_math_ ## py_name(mp_obj_t x_obj) { mp_int_t x = MICROPY_FLOAT_C_FUN(c_name)(mp_obj_get_float(x_obj)); return mp_obj_new_int(x); } \
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_## py_name ## _obj, mp_math_ ## py_name);
+#if MP_NEED_LOG2
+// 1.442695040888963407354163704 is 1/_M_LN2
+#define log2(x) (log(x) * 1.442695040888963407354163704)
+#endif
+
/// \function sqrt(x)
/// Returns the square root of `x`.
MATH_FUN_1(sqrt, sqrt)