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)

---------------------
作者:稚枭天卓
来源:CSDN
原文:https://blog.csdn.net/u013630349/article/details/47298977
版权声明:本文为博主原创文章,转载请附上博文链接!

python中的向上取整向下取整以及四舍五入的方法的更多相关文章

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

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

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

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

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

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

  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. SQLSERVER 数值 四舍五入取整 向上取整 向下取整

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

  8. C#以及Oracle中的上取整、下取整方法

    1.C#中: 上取整——Math.Ceiling(Double),即返回大于或等于指定双精度浮点数的最大整数(也可称为取天板值): eg:  Math.Ceiling(1.01)=2;      Ma ...

  9. #python计算结果百位500向下取整,(0-499取000,500-999取500)

    !/usr/bin/env python coding:utf-8 计算结果百位500向下取整,(0-499取000,500-999取500) import math calc_Amount = fl ...

随机推荐

  1. Linux Django项目部署

    步骤 .数据库的处理 1.1 上传bbs.sql 1.2 在mysql中创建bbs库,并导入数据库SQL脚本 mysql> create database bbs charset utf8mb4 ...

  2. Apache JMeter压力测试实例

    脚本录制 脚本录制,JMeter启用WEB代理,浏览器把代理上网设置为JMeter所在的IP地址,自己电脑就是127.0.0.1代理端口默认8080.至于浏览器修改代理上网服务器,不做截图. Jmet ...

  3. vue+cordova插件使用,bluetoothSerial.connect()连接失败

    这是GitHub地址https://github.com/don/BluetoothSerial

  4. sublime的Vue语法高亮插件安装

    1.准备语法高亮插件vue-syntax-highlight. 下载地址: https://github.com/vuejs/vue-syntax-highlight 下载页面并下载: 解开压缩包vu ...

  5. 关于读取excel 和 写excel

        def sync_db(data_list): '''Synchron potential student from excel to PrepareToCrm ''' push_list = ...

  6. SpringBoot配置分析、获取到SpringBoot配置文件信息以及几种获取配置文件信息的方式

    Spring入门篇:https://www.cnblogs.com/biehongli/p/10170241.html SpringBoot的默认的配置文件application.properties ...

  7. 学习笔记: yield迭代器

    yield 与 IEnumerable<T> 结对出现, 可实现按需获取 , 迭代器模式 static void Main(string[] args)         {         ...

  8. [转]安装v2ray,部署手机电脑***

    https://www.coding996.com/digitalocean-build-v2ray-0-1/https://blog.verkey.org/209.html 环境信息 服务器系统:C ...

  9. react学习一篇就够了

    webstrom自动格式化代码 命令 js框架 MVC 安装 npm install create-react-app -g 生成项目(项目名npm发包包命名规范 /^[a-z0-9_-]$/) cr ...

  10. B - Housewife Wind-树链剖分-树状数组

    思路:边权转化到点权上,统一把每一条边的边权集中到深度较深的点上去. #include<stdio.h> #include<iostream> #include<cstr ...