关于Round函数的问题 [英] question about Round function

查看:164
本文介绍了关于Round函数的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在c#项目中有工资表,想要收回净工资

,例如净工资是343.333我想把它舍入到345

我该如何解决?

解决方案

嗯。没有标准的方法可以做到这一点:舍入到最接近的五的倍数不是标准的数学运算。

但是,它并不复杂:

< pre lang =c#> Math.Round( value / 5 0 )* 5 ;

应该这样做。


hi
I have salaries table in my project in c# and want to Round the net salary
for example the net salary is 343.333 I want to Round it to 345
how can I solve that?

解决方案

Um. There is no standard method that will do that: rounding to "the nearest multiple of five" is not a standard maths operation.
But, it's not that complex:

Math.Round(value / 5.0) * 5;

Should do it.


这篇关于关于Round函数的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆