数学四舍五入
Math rounding up
我需要一些帮助,用 Math.Round()
将 0.73 舍入到 73。我很难找到方法。老师要我做一个方法,接受一个小数和return一个整数。
public static int Round(double number)
{
int numberLenght = number.ToString().Length;
int times = (int) Math.Pow(10, numberLenght-2);
return (int) (number*times);
}
你喜欢这样吗?
我需要一些帮助,用 Math.Round()
将 0.73 舍入到 73。我很难找到方法。老师要我做一个方法,接受一个小数和return一个整数。
public static int Round(double number)
{
int numberLenght = number.ToString().Length;
int times = (int) Math.Pow(10, numberLenght-2);
return (int) (number*times);
}
你喜欢这样吗?