Math.round(11.5)等于多少?Math.round(-11.5)等于多少?
- 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)等于多少?相关推荐
- Math.round(11.5)等于多少? Math.round(-11.5)等于多少?
Math.round()运算规则+0.5向下取整 package com.study.JavaBase;import org.junit.Test;/*** @Description Math.rou ...
- 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 ...
- java的round函数怎么用_Java Math round()用法及代码示例
java.lang.Math.round()是内置数学函数,它返回最接近参数的long.通过将1/2相加,将结果四舍五入为整数,再加上1/2后取结果的下限,并将结果强制转换为long类型. 如果参数为 ...
- math.trunc_JavaScript中带有示例的Math.trunc()方法
math.trunc JavaScript | Math.trunc()方法 (JavaScript | Math.trunc() Method) Math.trunc() is a function ...
- math.atan2_带有Python示例的math.atan2()方法
math.atan2 Python math.atan2()方法 (Python math.atan2() method) math.atan2() method is a library metho ...
- math.asin_JavaScript中带有示例的Math.asin()方法
math.asin JavaScript | Math.asin()方法 (JavaScript | Math.asin() Method) Math.asin() is a function in ...
- math.atan_JavaScript中带有示例的Math.atan()方法
math.atan JavaScript | Math.atan()方法 (JavaScript | Math.atan() Method) Math.atan() is a function in ...
- math.atan_Python中带有示例的math.atan()方法
math.atan Python math.atan()方法 (Python math.atan() method) math.atan() method is a library method of ...
- js math.hypot_带有Python示例的math.hypot()方法
js math.hypot Python math.hypot()方法 (Python math.hypot() method) math.hypot() method is a library me ...
- math.trunc_带有Python示例的math.trunc()方法
math.trunc Python math.trunc()方法 (Python math.trunc() method) math.trunc() method is a library metho ...
最新文章
- 语言小型心形图案代码_c语言心形告白代码实现
- RxJava使用(三)Scheduler 线程控制
- 熟练掌握python是什么概念-Python学到什么程度可以面试工作?
- 【安全牛学习笔记】SQLMAP- 自动注入
- 李爽久:平安云如何解决金融同业互联专线痛点
- 【亲测有效】Kali Linux无法安装网易云音乐的解决方案
- 腾讯视频怎么设置下载视频位置
- hadoop 单机单间_初学Hadoop之单机模式环境搭建
- Oracle_spatial的函数介绍
- Android学习笔记---19_采用ListView实现数据列表显示,以及各种适配器使用,和如何写自己的适配器
- 今日逢君君不识下一句
- python骗局-1.python真的是万恶之源么?(初识python)
- CSS之after与before的content 和 attr 配合使用
- Wireshark实战分析值ICMP协议(一)
- sql取逗号隔开的值_想学好Excel函数?你得先搞懂函数公式中逗号和星号的区别...
- python向mysql插入数据
- 【CRM】开源CRM
- 基于MiniC的语义分析(使用javacc)
- nc361t支持的服务器,使用5760/3850 WLC的外部RADIUS服务器EAP身份验证配置示例
- httpclient的两个重要的参数maxPerRoute及MaxTotal
热门文章
- 使用迭代器遍历List的时候修改List报ConcurrentModificationException异常原因分析
- Cocos2d-x win7 + vs2010 配置图文详解 .
- BCH链上交易量翻5倍的背后隐藏着哪些秘密?
- 仅支持BCH的众筹平台Coinfundr或能革新众筹业
- 绿色番薯 GHOST XP SP3 新春贺岁版
- 5.1基于JWT的认证和授权「深入浅出ASP.NET Core系列」
- 管理员修改文件的权限
- 文本编辑器ConsoleEditor_v1.2
- 对象类什么是面向对象(1)
- 移动互联网,安全厂商新战场