Python - Rounding by quarter-intervals

前端 未结 4 909
别跟我提以往
别跟我提以往 2020-12-10 11:08

I\'m running into the following issue:

Given various numbers like:

10.38

11.12

5.24

9.76

does an already \'built-in\' functio

4条回答
  •  臣服心动
    2020-12-10 12:00

    The solution of paxdiablo can be a little bit improved.

    def roundPartial (value, resolution):
    return round (value /float(resolution)) * resolution
    

    so the function is now: "data-type sensitive".

提交回复
热议问题