轮到最接近五 [英] Round to nearest five

查看:98
本文介绍了轮到最接近五的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个双数到最近的5。我找不到用Math.Round函数做的方法。我该怎么做?

I need to round a double to nearest five. I can't find a way to do it with the Math.Round function. How can I do this?

我想要的:

70 = 70
73.5 = 75
72 = 70
75.9 = 75
69 = 70

等等..

有没有办法做到这一点?

Is there an easy way to do this?

推荐答案

尝试:

Math.Round(value / 5.0) * 5;

这篇关于轮到最接近五的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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