在C#中的特定精度本轮下跌 [英] Round down by a specific precision in C#
本文介绍了在C#中的特定精度本轮下跌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何能圆下来双击
由特定的精度
。我需要得到一个双击
和最接近的值返回到两倍,是特定倍数的功能精度
并且比双低
因此,例如,如果精度= 2.5
9.3 ---> 7.5
12.5 ---> 12.5
13.0 ---> 12.5
14.5 ---> 12.5
15.5 ---> 15.0
解决方案
数学.Floor(价值/精度)*精密
How can I round down a double
by a specific precision
. I need a function that gets a double
and returns the closest value to that double that is a multiple of that specific precision
and is lower than the double.
So for example if the precision = 2.5
9.3 ---> 7.5
12.5 ---> 12.5
13.0 ---> 12.5
14.5 ---> 12.5
15.5 ---> 15.0
解决方案
Math.Floor(value / precision) * precision
这篇关于在C#中的特定精度本轮下跌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文