本题目选自CLR Team member Kathy Kam的BLOG。
请你不要编译运行下面的代码,说出运行结果。
class MainProgram
{
static void Main(string[] args)
{
double a = Convert.ToDouble("1.170404");
double b = Convert.ToDouble("2.170404");
double c = Convert.ToDouble("3.170404");
double d = Convert.ToDouble("4.170404");
Console.WriteLine((a == 1.170404));
Console.WriteLine((b == 2.170404));
Console.WriteLine((c == 3.170404));
Console.WriteLine((d == 4.170404));
}
}
{
static void Main(string[] args)
{
double a = Convert.ToDouble("1.170404");
double b = Convert.ToDouble("2.170404");
double c = Convert.ToDouble("3.170404");
double d = Convert.ToDouble("4.170404");
Console.WriteLine((a == 1.170404));
Console.WriteLine((b == 2.170404));
Console.WriteLine((c == 3.170404));
Console.WriteLine((d == 4.170404));
}
}
(如果你觉得这个题目很简单,你不妨在猜测一下答案之后实际运行一下试试看。不过园子里这么多高手,解答这个问题应该很轻松,所以请大家留情不要太鄙视我,呵呵)
补充:
请大家继续试一下5.170404,6..170404,7.170404,8.170404……
之后再下结论。