次のことを考慮してください。
#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でgcc4.5を使用しています。