fra*_*pet 1 c# math int rounding
我如何舍入(int)使得像(22536)这样的数字等于22000或23000?
我没有在Math类中找到一个特定的方法,Math.Round似乎只将double加倍到最接近的int.
Pat*_*man 10
通过使用模数:
int x = 1500; int result = x % 1000 >= 500 ? x + 1000 - x % 1000 : x - x % 1000;
x当数千个被剥离时,它检查是否有超过499,然后对其进行舍入.
x
归档时间:
10 年,6 月 前
查看次数:
6055 次
最近记录: