summaryrefslogtreecommitdiffstatshomepage
path: root/stmhal/math.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-08-05 14:13:05 +0000
committerDamien George <damien.p.george@gmail.com>2014-08-05 14:13:05 +0000
commit56da07dcfa8e73c15818453ae9f5ecba13718fc9 (patch)
tree6629d1d6d402d44bb1b51183bb65cddd962b6725 /stmhal/math.c
parentdd07023cb77894507a86a6f594fefb353d46963f (diff)
downloadmicropython-56da07dcfa8e73c15818453ae9f5ecba13718fc9.tar.gz
micropython-56da07dcfa8e73c15818453ae9f5ecba13718fc9.zip
stmhal, math: Define _M_LN2 if not already defined.
Addresses issue #790.
Diffstat (limited to 'stmhal/math.c')
-rw-r--r--stmhal/math.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/stmhal/math.c b/stmhal/math.c
index 91ffb2503f..9f0d312488 100644
--- a/stmhal/math.c
+++ b/stmhal/math.c
@@ -102,6 +102,10 @@ float copysignf(float x, float y) {
#ifdef log2f
#undef log2f
#endif
+// some compilers have _M_LN2 defined in math.h, some don't
+#ifndef _M_LN2
+#define _M_LN2 (0.69314718055994530942)
+#endif
float log2f(float x) { return logf(x) / (float)_M_LN2; }
static const float _M_LN10 = 2.30258509299404; // 0x40135d8e