2012-06-18 73 views
5

Android支持log2嗎?
我已經發現,Android不支持長雙。Android支持log2

當我試圖編譯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這裏。

+5

'的log 2(x)=日誌(X)/日誌(2)',這樣你就可以輕鬆地滾你自己(的計算'log(2)'首先)。 –

+0

謝謝你,我從學校的數學課程中記得它。但我不能這樣做,因爲我只能改變一些編輯鍵。或者找到另一種支持log2功能的神奇方式。我有興趣在默認情況下支持Android中的log2。正如我已經說過,也許有一些神奇的鑰匙。 – Arseniy

回答

4

看起來Android默認不支持log2功能。因爲我在這個函數的源代碼中沒有找到任何地方。

7

您的神奇方式就在這裏。我測試過它,並努力:

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

更快的計算:

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