import math

f = 11.2
print math.ceil(f) #向上取整
print math.floor(f) #向下取整
print round(f) #四舍五入 #这三个函数的返回结果都是浮点型

Python 之 向上取整、向下取整以及四舍五入函数的更多相关文章

  1. C#采用的是“四舍六入五成双”、上取整、下取整

    c# 四舍五入.上取整.下取整 Posted on 2010-07-28 12:54 碧水寒潭 阅读(57826) 评论(4) 编辑 收藏 在处理一些数据时,我们希望能用“四舍五入”法实现,但是C#采 ...

  2. c# 四舍五入、上取整、下取整

    在处理一些数据时,我们希望能用“四舍五入”法实现,但是C#采用的是“四舍六入五成双”的方法,如下面的例子,就是用“四舍六入五成双”得到的结果: double d1 = Math.Round(1.25, ...

  3. python中的向上取整向下取整以及四舍五入的方法

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

  4. Python向上取整,向下取整以及四舍五入函数

    import math f = 11.2 print math.ceil(f) #向上取整 print math.floor(f) #向下取整 print round(f) #四舍五入 #这三个函数的 ...

  5. python向上取整 向下取整

    向上取整 ceil() 函数返回数字的向上取整整数,就是返回大于等于变量的最近的整数. ceil()是不能直接访问的,需要导入 math 模块. import math math.ceil( x ) ...

  6. python取整函数 向上取整 向下取整 四舍五入

    向上取整 >>> import math >>> math.ceil(3.5) 4 >>> math.ceil(3.4) 4 >>&g ...

  7. c#中取整,向上取,向下取

    Math.Ceiling()向上取整, Math.Floor()向下取整 示例: d = 4.56789 Math.Ceiling(Convert.ToDecimal(d)).ToString();M ...

  8. SQLSERVER 数值 四舍五入取整 向上取整 向下取整

    [四舍五入取整截取] select round(54.56,0) [向下取整截取] SELECT floor(54.56) [向上取整截取]  SELECT   ceiling(13.15)

  9. c# 三种取整方法 向上取整 向下取整 四舍五入

    Math.Round:四舍六入五取整 Math.Ceiling:向上取整,只要有小数都加1 Math.Floor:向下取整,总是舍去小数

  10. java向上取整向下取整

    向上取整用Math.ceil(double a) 向下取整用Math.floor(double a) 举例: public static void main(String[] args) throws ...

随机推荐

  1. 【驱动笔记10】再谈IRP

    文章作者:grayfox作者主页:http://nokyo.blogbus.com原始出处:http://www.blogbus.com/nokyo-logs/34010655.html 这一节会对I ...

  2. Python 元组 min() 方法

    描述 Python 元组 min() 方法返回元组中元素最小值. 语法 min() 方法语法: min(T) 参数 T -- 指定的元组. 返回值 返回元组中元素最小值. 实例 以下实例展示了 min ...

  3. kafka linux 启动脚本 sample

    #!/bin/sh # # chkconfig: 345 99 01 # description: Kafka # # File : Kafka # # Description: Starts and ...

  4. mysql格式化日期

    mysql查询记录如果有时间戳字段时,查看结果不方便,不能即时看到时间戳代表的含义,现提供mysql格式换时间函数,可以方便的看到格式化后的时间. 1. DATE_FORMAT() 函数用于以不同的格 ...

  5. scala-trait实现AOP编程

    步骤1:声明表示基本动作方法的模块Taction //声明表示基本动作方法的模块Taction trait TAction { def doAction } 步骤2:定义一下加入了前置处理和后置处理的 ...

  6. 【Android】16.3 带Intent过滤器的Services

    分类:C#.Android.VS2015: 创建日期:2016-03-01 一.简介 这一节演示带Intent过滤器的Services的基本用法. 1.配置Intent Filter 不论是本地解决方 ...

  7. 递增和递减进度条CCProgressTimer

    关于scheduleUpdate看这篇即可 http://www.benmutou.com/blog/archives/56 接下来是示例代码: CCSize size = CCDirector::s ...

  8. nginx负载均衡的策略

    1.轮询(默认) 应用程序轮流来响应请求 2.最少连接(least-conn)    请求被分配到活动连接最少的服务器上 3.ip-hash    通过一个hash函数决定哪个服务器来响应用户的请求( ...

  9. 黑客编程教程(十五)HTTP代理

    #include <stdio.h> #include <winsock2.h> #define MAXBUFLEN 20480 #define HTTPADDLEN 50 # ...

  10. 黑客编程教程(一)了解Windows机制

    第一节 了解Windows机制 Windows 是一个“基于事件的,消息驱动的”操作系统. 在Windows下执行一个程序,只要用户进行了影响窗口的动作(如改变窗口大小或移动.单击鼠标等)该动作就会触 ...