等式的错误结果
Wrong result on equation
我有这个等式:1 - (1 + 0.001) -48
结果应该是:0.379
但在我的代码中发生了这种情况:
public static void Main(string[] args)
{
double test = Math.Pow((1 - (1 + 0.001)), -48);
Console.WriteLine("" + test);
}
Result: 1,00000000000529E+144
还有这个
public static void Main(string[] args)
{
double test = Math.Pow(-48, (1 - (1 + 0.001)));
Console.WriteLine("" + test);
}
Result: Nan
计算此操作的正确方法是什么?
应该是:
double test = 1 - Math.Pow((1 + 0.01), -48);
我有这个等式:1 - (1 + 0.001) -48 结果应该是:0.379
但在我的代码中发生了这种情况:
public static void Main(string[] args)
{
double test = Math.Pow((1 - (1 + 0.001)), -48);
Console.WriteLine("" + test);
}
Result: 1,00000000000529E+144
还有这个
public static void Main(string[] args)
{
double test = Math.Pow(-48, (1 - (1 + 0.001)));
Console.WriteLine("" + test);
}
Result: Nan
计算此操作的正确方法是什么?
应该是:
double test = 1 - Math.Pow((1 + 0.01), -48);