string[] val = { "18.6", "7", "18.6", "18.6", "18.6", "18.6" };
int int_n = val.Length;
object N = (double)int_n;
double[] double_xiax = new double[int_n];
for (int i = 0; i < val.Length; i++)
{
double_xiax[i] = double.Parse(val[i]) / 100;
}
int int_n = val.Length;
object N = (double)int_n;
double[] double_xiax = new double[int_n];
for (int i = 0; i < val.Length; i++)
{
double_xiax[i] = double.Parse(val[i]) / 100;
}
context.Response.Write(double_xiax[0]+"<Br/>");
以上代码执行后,输出的结果是0.186。看似是没问题的。但是如果断点调试的话,会发现double_xiax[0]的值是0.18600000000000003。针对这种问题,可以这样处理。
double_xiax[i] =Convert.ToDouble(Convert.ToDecimal(val[i]) / 100);这样断点调试的时候,double_xiax[0]的值就是0.186。