考虑以下:
#include <iostream>
#include <cmath>
int main()
{
using std::cout;
using std::endl;
const long double be2 = std::log(2);
cout << std::log(8.0) / be2 << ", " << std::floor(std::log(8.0) / be2)
<< endl;
cout << std::log(8.0L) / be2 << ", " << std::floor(std::log(8.0L) / be2)
<< endl;
}
输出
3, 2
3, 3
为什么输出不同?我在这里想念什么?
这里也是键盘的链接:http: //codepad.org/baLtYrmy
如果这很重要,我在 linux 上使用 gcc 4.5。