统计学中普遍遵循四舍六入五成双
例:32.6752 -》32.67
例:32.6755 -》32.67
注:String.Format() .frame work 4.7.2是四舍五入;.net6 .net7则符合四舍六入五成双;其余版本没有进行测试。
// .frame work 4.7.2 var Distance = 32675; var a = String.Format("{0:N2}", Distance / 1000.0);//a = 32.68 var b = System.Math.Round((Distance/ 1000.0), 2) ;//b = 32.67
//.net6 .net7 var Distance = 32675; var a = String.Format("{0:N2}", Distance / 1000.0);//a = 32.67 var b = System.Math.Round((Distance/ 1000.0), 2) ;//b = 32.67
标签:Distance,32.67,String,Format,C#,1000.0,var From: https://www.cnblogs.com/yyd-sun/p/18219785