Does Android support log2
Asked Answered
L

2

5

Does android supports log2 ?
I already find that android doesnt support long double.

When i tried to compile cdce3.c I received following error:

g++.dg/cdce3.C: In function 'void mlog2f(int)':
g++.dg/cdce3.C:87: error: 'log2f' was not declared in this scope
g++.dg/cdce3.C: In function 'void mlog2(int)':
g++.dg/cdce3.C:87: error: 'log2' was not declared in this scope
g++.dg/cdce3.C: In function 'void olog2f(int)':
g++.dg/cdce3.C:108: error: 'log2f' was not declared in this scope
g++.dg/cdce3.C: In function 'void olog2(int)':
g++.dg/cdce3.C:108: error: 'log2' was not declared in this scope

Part of cdce3.c source code:

#define DEF_MATH_FUNC(prefix, name) NI void prefix##name##f (int x) \
{ \
  float yy = name##f ((float) x); \
  STORE_RESULT; \
} \
NI void prefix##name (int x) \
{ \
  double yy = name ((double)x); \
  STORE_RESULT; \
}
#endif
.........
DEF_MATH_FUNC (m,log2)
DEF_MATH_FUNC (o,log2)

find full source code here.

Lowborn answered 18/6, 2012 at 9:28 Comment(2)
log2(x) = log(x) / log(2), so you can easily roll your own (compute log(2) first).Calorie
Thank you, i remember it from school math program. But i can not do it, because all i can it change some compilation keys. Or find another magical way for supporting log2 function. I am interested in supporting the log2 in Android by default. As i already said maybe with some magical keys.Lowborn
L
4

Looks like Android doesn't support log2 function by default. Because i don't found nowhere in source codes determining of this function.

Lowborn answered 28/6, 2012 at 7:14 Comment(0)
D
8

Your magical way is here. I've tested it and worked:

make CXXFLAGS="-Dlog2\(x\)=\(log\(x\)/log\(2\)\)"

faster computation:

make CXXFLAGS="-Dlog2\(x\)=\(log\(x\)*1.4426950408889634\)"
Danielladanielle answered 27/2, 2016 at 17:14 Comment(1)
Shouldn't the 1/log(2) value be be actually 3.32192809489?Wesleywesleyan
L
4

Looks like Android doesn't support log2 function by default. Because i don't found nowhere in source codes determining of this function.

Lowborn answered 28/6, 2012 at 7:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.