• ceil的英文意义是天花板,该方法就表示向上取整,Math.ceil(11.3)的结果为12,Math.ceil(-11.6)的结果为-11;
  • floor的英文是地板,该方法就表示向下取整,Math.floor(11.6)的结果是11,Math.floor(-11.4)的结果-12;
  • round方法,他表示“四舍五入”,算法为Math.floor(x+0.5),即将原来的数字加上0.5后再向下取整,所以,Math.round(11.5)的结果是12,Math.round(-11.5)的结果为-11.

舍掉小数取整:Math.floor(2)=2
舍掉小数取整:Math.floor(2.1)=2
舍掉小数取整:Math.floor(-2.1)=-3
舍掉小数取整:Math.floor(-2.5)=-3
舍掉小数取整:Math.floor(-2.9)=-3
四舍五入取整:Math.rint(2)=2
四舍五入取整:Math.rint(2.1)=2
四舍五入取整:Math.rint(-2.5)=-2
四舍五入取整:Math.rint(2.5)=2
四舍五入取整:Math.rint(2.9)=3
四舍五入取整:Math.rint(-2.9)=-3
四舍五入取整:Math.rint(-2.49)=-2
四舍五入取整:Math.rint(-2.51)=-3
凑整:Math.ceil(2)=2
凑整:Math.ceil(2.1)=3
凑整:Math.ceil(2.5)=3
凑整:Math.ceil(2.9)=3
舍掉小数取整:Math.floor(-2)=-2
舍掉小数取整:Math.floor(-2.1)=-3
舍掉小数取整:Math.floor(-2.5)=-3
舍掉小数取整:Math.floor(-2.9)=-3
凑整:Math.ceil(-2)=-2
凑整:Math.ceil(-2.1)=-2
凑整:Math.ceil(-2.5)=-2
凑整:Math.ceil(-2.9)=-2
Math.round(3.14)3
Math.round(3.5)4
Math.round(-3.14)-3
Math.round(-3.5)-3

  • 总结:floor向下取整,ceil向上取整;round和rint四舍五入,取绝对值后舍入,然后加上符号,遇到.5的时候向绝对值小的方向舍之。

Math.round(11.5)等于多少?Math.round(-11.5)等于多少?相关推荐

  1. Math.round(11.5)等于多少? Math.round(-11.5)等于多少?

    Math.round()运算规则+0.5向下取整 package com.study.JavaBase;import org.junit.Test;/*** @Description Math.rou ...

  2. java面试题33 Math.round(11.5) 等于多少 (). Math.round(-11.5) 等于多少 ( ).

    java面试题33 Math.round(11.5) 等于多少 (). Math.round(-11.5) 等于多少 (  ). A 11 ,-11 B 11 ,-12 C 12 ,-11 D 12 ...

  3. java的round函数怎么用_Java Math round()用法及代码示例

    java.lang.Math.round()是内置数学函数,它返回最接近参数的long.通过将1/2相加,将结果四舍五入为整数,再加上1/2后取结果的下限,并将结果强制转换为long类型. 如果参数为 ...

  4. math.trunc_JavaScript中带有示例的Math.trunc()方法

    math.trunc JavaScript | Math.trunc()方法 (JavaScript | Math.trunc() Method) Math.trunc() is a function ...

  5. math.atan2_带有Python示例的math.atan2()方法

    math.atan2 Python math.atan2()方法 (Python math.atan2() method) math.atan2() method is a library metho ...

  6. math.asin_JavaScript中带有示例的Math.asin()方法

    math.asin JavaScript | Math.asin()方法 (JavaScript | Math.asin() Method) Math.asin() is a function in ...

  7. math.atan_JavaScript中带有示例的Math.atan()方法

    math.atan JavaScript | Math.atan()方法 (JavaScript | Math.atan() Method) Math.atan() is a function in ...

  8. math.atan_Python中带有示例的math.atan()方法

    math.atan Python math.atan()方法 (Python math.atan() method) math.atan() method is a library method of ...

  9. js math.hypot_带有Python示例的math.hypot()方法

    js math.hypot Python math.hypot()方法 (Python math.hypot() method) math.hypot() method is a library me ...

  10. math.trunc_带有Python示例的math.trunc()方法

    math.trunc Python math.trunc()方法 (Python math.trunc() method) math.trunc() method is a library metho ...

最新文章

  1. 语言小型心形图案代码_c语言心形告白代码实现
  2. RxJava使用(三)Scheduler 线程控制
  3. 熟练掌握python是什么概念-Python学到什么程度可以面试工作?
  4. 【安全牛学习笔记】SQLMAP- 自动注入
  5. 李爽久:平安云如何解决金融同业互联专线痛点
  6. 【亲测有效】Kali Linux无法安装网易云音乐的解决方案
  7. 腾讯视频怎么设置下载视频位置
  8. hadoop 单机单间_初学Hadoop之单机模式环境搭建
  9. Oracle_spatial的函数介绍
  10. Android学习笔记---19_采用ListView实现数据列表显示,以及各种适配器使用,和如何写自己的适配器
  11. 今日逢君君不识下一句
  12. python骗局-1.python真的是万恶之源么?(初识python)
  13. CSS之after与before的content 和 attr 配合使用
  14. Wireshark实战分析值ICMP协议(一)
  15. sql取逗号隔开的值_想学好Excel函数?你得先搞懂函数公式中逗号和星号的区别...
  16. python向mysql插入数据
  17. 【CRM】开源CRM
  18. 基于MiniC的语义分析(使用javacc)
  19. nc361t支持的服务器,使用5760/3850 WLC的外部RADIUS服务器EAP身份验证配置示例
  20. httpclient的两个重要的参数maxPerRoute及MaxTotal

热门文章

  1. 使用迭代器遍历List的时候修改List报ConcurrentModificationException异常原因分析
  2. Cocos2d-x win7 + vs2010 配置图文详解 .
  3. BCH链上交易量翻5倍的背后隐藏着哪些秘密?
  4. 仅支持BCH的众筹平台Coinfundr或能革新众筹业
  5. 绿色番薯 GHOST XP SP3 新春贺岁版
  6. 5.1基于JWT的认证和授权「深入浅出ASP.NET Core系列」
  7. 管理员修改文件的权限
  8. 文本编辑器ConsoleEditor_v1.2
  9. 对象类什么是面向对象(1)
  10. 移动互联网,安全厂商新战场