Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试将数字四舍五入到 10
前任:
6变成10
4变成0
11变成10
14变成10
17变成20
我该怎么做?据我所知,Math.Round 不适用于此。
对于double(float并且decimal需要额外的转换):
double
float
decimal
value = Math.Round(value / 10) * 10;
对于int:
int
value = (int) (Math.Round(value / 10.0) * 10);