python 向上取整ceil 向下取整floor 四舍五入round
程序员文章站
2024-01-04 12:56:58
...
#encoding:utf-8 import math #向上取整 http://www.manongjc.com/article/1335.html print "math.ceil---" print "math.ceil(2.3) => ", math.ceil(2.3) print "math.ceil(2.6) => ", math.ceil(2.6) #向下取整 http://www.manongjc.com/article/1336.html print "\nmath.floor---" print "math.floor(2.3) => ", math.floor(2.3) print "math.floor(2.6) => ", math.floor(2.6) #四舍五入 http://www.manongjc.com/article/1337.html print "\nround---" print "round(2.3) => ", round(2.3) print "round(2.6) => ", round(2.6) #这三个的返回结果都是浮点型 http://www.manongjc.com/article/1338.html 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)
运行结果:
推荐阅读
-
python 向上取整ceil 向下取整floor 四舍五入round
-
PHP取整函数:ceil,floor,round,intval的区别详细解析_php技巧
-
PHP取整函数:ceil,floor,round,intval的区别详细解析
-
ios的向上,向下以及四舍五入的取整方式
-
SQL四舍五入、向下取整、向上取整函数介绍
-
PHP取整函数:ceil,floor,round,intval的区别详细解析
-
php 取整函数(floor,ceil,round,intval)_PHP教程
-
ios的向上,向下以及四舍五入的取整方式
-
php取整函数ceil,floor,round,intval函数的区别
-
php取整函数ceil,floor,round,intval函数的区别