【问题标题】:Floor to another decimal precision下限到另一个小数精度
【发布时间】:2018-05-05 14:45:09
【问题描述】:

如果这听起来很简单,我很抱歉,但它就在我的盲点上

如何将“0.4921”之类的数字转换为另一个数字的下限,即

  • 0.4921 精度为 0.005 为 0.490
  • 0.4921 精度为 0.05 为 0.45
  • 0.4921 精度为 0.1 为 0.40

【问题讨论】:

    标签: c# algorithm numbers


    【解决方案1】:

    你要的答案是精度的整数倍。

    因此将数字除以精度、下限、上限或舍入;然后乘以精度。

    return Math.Floor(number / precision) * precision;
    

    【讨论】:

      猜你喜欢
      • 2013-02-11
      • 2017-02-05
      • 1970-01-01
      • 1970-01-01
      • 2014-08-11
      • 2020-05-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多