我有这个代码.为什么它会-nan在主程序中返回一个值时产生?
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace::std;
float f(float x)
{
float result = -5 * x * x - 2 * x + 1;
return powf(result, (float)1/(float)3);
}
int main()
{
cout<<f(-1)<<endl;
getchar();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这让我很困惑.据我所知,我使用合适的数据类型.