翻译错误...原文...ToEven When a number is halfway between two others, it is rounded toward the nearest even number. AwayFromZero When a number is halfway between two others, it is rounded toward the nearest number that is away from zero.
int louzhu=166.665; int louzhuxiangyaodeshuzi=math.round(louzhu+0.001); OK 解决问题
上面的话是转来的
Response.Write(Math.Round(d, 2, MidpointRounding.AwayFromZero));
Console.WriteLine(Math.Round(166.665,2, MidpointRounding.AwayFromZero));
//166.67
Math.Round(3.45, 1); //Returns 3.4.
Math.Round(3.46, 1); //Returns 3.5.
若要控制 Math.Round(Decimal, Int32) 方法使用的舍入类型,请调用 Math.Round(Decimal, Int32, MidpointRounding) 重载。
AwayFromZero 当一个数字是其他两个数字的中间值时,会将其舍入为两个值中绝对值较小的值。Console.WriteLine(Math.Round(166.665,2, MidpointRounding.AwayFromZero));的结果结果为什么不是166.66啊,不是取绝对值小的那个吗··
AwayFromZero 当一个数字是其他两个数字的中间值时,会将其舍入为两个值中绝对值较小的值。
可以试下:
Math.Round(166.665, 2,MidpointRounding.ToEven/*若为正数,用绝对值较大的值*/);
试下了.
http://msdn.microsoft.com/en-us/library/ms131274.aspx
AwayFromZero When a number is halfway between two others, it is rounded toward the nearest number that is away from zero.
int louzhuxiangyaodeshuzi=math.round(louzhu+0.001);
OK 解决问题