5をnとpとして2を書くときはいつも、出力は24 ...私に何が間違っているか教えてください。それ以外の数字は完全にうまくいきます。C++のpowメソッドの5の威力にエラーがあります
#include<iostream>
#include<conio.h>
#include<math.h>
using namespace std;
int main()
{
double n, p;
cout << "enter the number" <<endl;
cin >> n;
cout << "enter the power" <<endl;
cin >> p;
int result = pow(n, p);
cout << "Result is " << result;
return 0;
}
'ダブル、おそらく' 24.999999999 .... '、あなたが' int'でそれを保存するとき、 '24'をされるが、私は再現できません:http://ideone.com/jPgljt – mch
詳細な答えhttps://stackoverflow.com/a/25678721/3701834 – aniliitb10