python 精确计算与向上取整 decimal math.ceil

1.  精确计算

python的float型不精确,需要导入decimal包,以下是不精确举例:

导入decimal包后:

2.  向上取整

一般的取整数(向下取整):

向上取整的方法:

 

posted @ 2018-10-14 17:34  山…隹  阅读(2391)  评论(0编辑  收藏  举报