以这种方式在 python 中 Ceil 任何数字 - 2.3、2.1、1.9、2.6。到 2.5、2.5、2、3,即加法导致 .5 或 1 的加法,以最接近的 [重复] 为准

Ceil any number in python this way - 2.3, 2.1, 1.9, 2.6. to 2.5, 2.5, 2, 3 i.e. addition leads to addition of .5 or 1 whichever is closest [duplicate]

提问人:nitinkhatri749 提问时间:11/17/2022 最后编辑:wovanonitinkhatri749 更新时间:11/17/2022 访问量:131

问:

默认上限不是这样工作的。 Ceil 应该以这种方式工作—— 示例 2 - 3.1, 4.5, 5.9 天花板后 - 3.5、4.5、6

Python CEIL

评论

0赞 0x0fba 11/17/2022
回答了你的问题吗?

答:

1赞 compli 11/17/2022 #1
def roundOffnumber (number):
 return (math.ceil(number*2))/2