【发布时间】:2019-02-27 17:46:20
【问题描述】:
我一直在搜索这个问题几个小时,但我没有找到我的答案,所以我问它:
我正在寻找将25,599,999 舍入为25,000,000 或将25,599,999 舍入为30,000,000 的方法或东西:
int num1 = 25599999;
Console.WriteLine(RoundDown(num1, 6 /* This is the places (numbers from end that must be 0) */)) // Should return 25,000,000;
或四舍五入:
int num1 = 25599999;
Console.WriteLine(RoundUp(num1, 6 /* This is the places (numbers from end that must be 0) */)) // Should return 30,000,000;
注意:我不是在寻找四舍五入的方法。
【问题讨论】:
-
搜索“四舍五入”有很多答案
-
你尝试了什么?显示您的代码。我认为您无法直接找到这种自定义。
-
Math.Floor,Math.Ceiling? -
我不是在寻找四舍五入的十进制数。 @Dmitry Bychenko
-
不要投反对票,阅读问题并记住,我并不愚蠢地提出已被多次回答的问题。
标签: c# .net numbers int rounding