Snippet:计算二次方程的判别式(圆盘):
Disc = Math.Sqrt((secondCoefficient * secondCoefficient) - (4 * firstCoefficient * thirdCoefficient));
if (Disc < 0)
{
MessageBox.Show("Its imaginary discriminant which can't be calculated!");
}
else
{
MessageBox.Show("The Discriminant of the required quadratic equation is : " + Convert.ToString(Disc), "Discriminant Calculator");
}
输出: Disc = -Ve(负值) 显示文本:所需二次方程的判别式为:NaN 你能详细解释一下吗?我试图理解但未能找到正确的理由。
问题:如果Disc值为负数,那么&#39;如果&#39;声明返回为&#39; false&#39;,而它应返回为&#39; true&#39;。