首页 > 编程语言 > 详细

python 向上取整ceil 向下取整floor 四舍五入round

时间:2014-05-08 12:10:26      阅读:598      评论:0      收藏:0      [点我收藏+]
bubuko.com,布布扣
#encoding:utf-8
import math

#向上取整
print "math.ceil---"
print "math.ceil(2.3) => ", math.ceil(2.3)
print "math.ceil(2.6) => ", math.ceil(2.6)

#向下取整
print "\nmath.floor---"
print "math.floor(2.3) => ", math.floor(2.3)
print "math.floor(2.6) => ", math.floor(2.6)

#四舍五入
print "\nround---"
print "round(2.3) => ", round(2.3)
print "round(2.6) => ", round(2.6)

#这三个的返回结果都是浮点型
print "\n\nNOTE:every result is type of float"
print "math.ceil(2) => ", math.ceil(2)
print "math.floor(2) => ", math.floor(2)
print "round(2) => ", round(2)
bubuko.com,布布扣

运行结果:

bubuko.com,布布扣

 

 

python 向上取整ceil 向下取整floor 四舍五入round,布布扣,bubuko.com

python 向上取整ceil 向下取整floor 四舍五入round

原文:http://www.cnblogs.com/lipijin/p/3714312.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!