62,046
社区成员
发帖
与我相关
我的任务
分享
double[] values = { 1.120, 2.121, 3.124, 4.125, 5.129 };
foreach (double value in values)
{
string r = (Math.Floor(value * 100 + 0.9) / 100).ToString("F2");
Response.Write(r + "<br/>");
}
输出:
1.12
2.13
3.13
4.13
5.13
double a=123.120;
string str=a.ToString();
int count=str.LastIndexOf(".");
取值为0 舍去
其他 则增加0.01