Does Android support log2

Does android support log2?
I already found that android does not support long double.

When I tried to compile cdce3.c, I got the 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 the source code cdce3.c:

#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 the full source code here.

+5
source share
2 answers

It seems that Android does not support the log2 function by default. Because I did not find anywhere in the source code definition of this function.

+4
source

Your magical path is here. I tested it and worked:

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

faster calculation:

make CXXFLAGS="-Dlog2\(x\)=\(log\(x\)*1.4426950408889634\)"
+7
source

All Articles