Math.Round是"就近舍入",当要舍入的是5时与"四舍五入"不同(取偶数),如:
Math.Round(0.5,0)=0
Math.Round(1.5,0)=2
Math.Round(2.5,0)=2
Math.Round(3.5,0)=4
....
Math.Ceiling(3.1)=4;
Math.Floor(3.9)=3;
取天板值与地板值,与"四舍五入"无关。
其实Floor的结果与(int)相同,因此也可以这样写Math.Floor((double)2/3+0.5)
Math.Round(0.5,0)=0
Math.Round(1.5,0)=2
Math.Round(2.5,0)=2
Math.Round(3.5,0)=4
....
Math.Ceiling(3.1)=4;
Math.Floor(3.9)=3;
取天板值与地板值,与"四舍五入"无关。
其实Floor的结果与(int)相同,因此也可以这样写Math.Floor((double)2/3+0.5)