lua math.floor 实现四舍五入:

lua 中的math.floor函数是向下取整函数。

  math.floor(5.123)  -- 5

  math.floor(5.523)   -- 5

用此特性实现四舍五入

  math.floor(5.123 + 0.5)  -- 5

  math.floor(5.523 + 0.5)  -- 6

也就是对math.floor函数的参数进行 “+ 0.5” 计算

math.floor实现四舍五入的更多相关文章

  1. Math函数的"四舍五入",Floor,Ceiling,Round的一些注意事项!

    1.Math.Round:四舍六入五取偶 引用内容 Math.Round(0.0) //0Math.Round(0.1) //0Math.Round(0.2) //0Math.Round(0.3) / ...

  2. Javascript Math.ceil()与Math.round()与Math.floor()区别

    Math.ceil()向上舍入 1 2 3 alert(Math.ceil(20.1)) //输出 21 alert(Math.ceil(20.5)) //输出 21 alert(Math.ceil( ...

  3. Java Math floor round ceil 函数

    public final class Math extends Object public static double floor(double a) public static long round ...

  4. js中Math.round、parseInt、Math.floor和Math.ceil小数取整总结

    Math.round.parseInt.Math.floor和Math.ceil 都可以返回一个整数,具体的区别请看下面的总结. 一.Math.round 作用:四舍五入,返回参数+0.5后,向下取整 ...

  5. Javascript -- Math.round()、Math.ceil()、Math.floor()、parseInt去小数取整总结

    一.Math.round() 作用:四舍五入返回整数.(返回参数+0.5后,向下取整) Math.round(5.57) //返回6 Math.round(2.4) //返回2 Math.round( ...

  6. Math.round()、Math.ceil()、Math.floor()与Math.random()的区别?

    Math.round(x) 四舍五入 加上0.5向下取整 Math.round(1.5) 2 Math.round(-11.5) -11 Math.round(-11.2) -10 Math.ceil ...

  7. JavaScript中的Math.ceil()、Math.round()、Math.floor()

    1. Math.ceil():向上取整(指取大于该浮点数的最小整数) 2. Math.round():四舍五入取整(注意:当该浮点数距离两端整数一样时,取较大的那个整数,如Math.round(-1. ...

  8. math ceil以及math floor,math:round

    ◎Math.ceil()执行向上舍入,即它总是将数值向上舍入为最接近的整数:◎Math.floor()执行向下舍入,即它总是将数值向下舍入为最接近的整数:◎Math.round()执行标准舍入,即它总 ...

  9. Math.floor(Math.random()*3+1)

    Math.random():获取0~1随机数 Math.floor() method rounds a number DOWNWARDS to the nearest integer, and ret ...

随机推荐

  1. 图解Microsoft SQL Server——“远程过程调用失败 [0x800706be] 错误“。

    今天在配置SqlServer启动参数时,发现"开始菜单"->“配置工具”->“SQL Server 配置管理器”中的“SQL Server 服务”一项,右边栏里显示的是 ...

  2. B - The Suspects(并查集)

    B - The Suspects Time Limit:1000MS     Memory Limit:20000KB     64bit IO Format:%lld & %llu Desc ...

  3. Linux 常用命令缩写及对应的

    0.项目名: Linux -- LINUs' uniX (开个玩笑不是这样的,别当真) GNU -- Gnu is Not Unix1.目录名: /boot:顾名思义 /root :同上 /run:同 ...

  4. Quality of service

    w https://en.wikipedia.org/wiki/Quality_of_service Quality of service (QoS) is the overall performan ...

  5. diy 重要的不是这个工具怎么解决了问题

    w 0-这个工具解决了什么问题? 1-diy,怎么解决这个工具解决了的问题? 2-是否diy实现?实现了,对比,优化:反之,分析借鉴,吸收优化. 重要的不是git怎样解决了git已经解决的问题.

  6. python问号堂--第二篇

    1.分别书写数字5,10,32,7的二进制表示? 5---0b101      10---0b1010     32---0b100000    7---0b111 以上结果可以bin()来检测 2. ...

  7. Oracle 12c 读书笔记(二):Oracle数据库体系结构

    以11g来分析 数据库实例包括:SGA和一系列后台管理.监控简称 数据库包括三种文件:数据文件.控制文件.重做日志文件 数据库实例和数据库是Orale数据库体系的核心部分 Oracle服务器和实例 实 ...

  8. python 时间模块小结

    python有两个重要的时间模块,分别是time和datetime time模块 表示时间的几种方法 时间元组 time.struct_time( tm_year=2016, tm_mon=7, tm ...

  9. 阿里云免费SSL证书申请及配置过程centos7,Nginx

    1:进入购买,等待审核,审核通过后下在一个压缩包 ,里面包含两个文件一个 214979907780888.key 一个214979907780888.pem (如果不在阿里买,也可以在其它平台买,或者 ...

  10. Spring学习笔记2—AOP

    1.AOP概念 AOP(Aspect Oriented Programming):面向切面编程,AOP能够将那些与业务无关,却为业务模块所共同调用的应用(例如事务处理.日志管理.权限控制等)封装起来, ...