例如:13.799〜13.80,13.023〜13.02,27.8555〜27.86此上存在的任何算法
round(., 2)
舍入到2个十进制数字。在您需要时,您可以使用以下方式:
public static void Main()
{
//Array where the Information is stored
double[] values = { 13.799, 13.023, 27.8555 };
//for each value in the array
foreach (double value in values)
//write it to the console like unrounded-value => rounded-value
//specify on how many Digit you want to round
Console.WriteLine("{0} => {1}", value, Math.Round(value, 2));
}
该示例显示以下输出:
13.799 => 13.80 13.023 => 13.02 27.8555 => 27.86
附加说明:[十进制的值四舍五入为4而不是5,因为此重载使用默认的ToEven约定。