Logo

郎哥编程

数值精度取舍

2021-11-11 704

函数声明:

round(number[, ndigits])

返回 number 舍入到小数点后 ndigits 位精度的值。 如果 ndigits 被省略或为 None,则返回最接近输入值的整数。


案例代码:

>>> num = 3.15689
>>> round(num)
3
>>> num = 3.65689
>>> round(num)
4
>>> round(num,3)
3.657
>>>


代码在线纠错(通义千问 qwen-max)

支持粘贴多个代码文件,提交后由阿里云通义千问自动分析代码漏洞、语法错误、逻辑问题并给出修改建议。
您已解锁 AI 代码纠错功能,可正常使用!

评论区

登录 后发表评论
暂无评论