Android是否支持log2

时间:2012-06-18 09:28:16

标签: android c android-x86

android是否支持log2?
我已经发现android不支持long double。

当我尝试编译cdce3.c时收到以下错误:

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

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)

在这里找到完整的source code

2 个答案:

答案 0 :(得分:8)

你的神奇方式就在这里。我测试了它并且工作了:

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

更快的计算:

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

答案 1 :(得分:4)

默认情况下,Android似乎不支持log2功能。因为我在源代码中找不到确定此功能的地方。

相关问题