Math.round() :round周围,求一个附近的 整数

小数点后第一位 < 5
正数:Math.round(10.48)       //  10
负数:Math.round(-10.45)     //  -10
小数点后第一位  > 5 
正数:Math.round(10.68)       //  11 
负数:Math.round(-10.68)      //  -11
小数点后第一位  === 5
正数:Math.round(11.5)         // 12
负数:Math.round(-11.5)        // -11
 
总结:正数情况 小数点后一位大于或等于5 全部往上的取值,小于5往下的取值
   负数情况 小数点后一位小于5 或等于5往上取值, 大于5往下取值
 
Math.ceil() :ceil天花板意思,全部往大的取值
Math.ceil(11.46)  Math.ceil(11.68)   Math.ceil(11.5)        // 12
Math.ceil(-11.46) Math.ceil(-11.68)  Math.ceil(-11.5)     // -11
 
Math.floor():floor:“地板” 意思 全部往小的取值
Math.floor(11.46)            //11
Math.floor(11.68)            //11
Math.floor(11.5)              //11
 
Math.floor(-11.46)          // -12
Math.floor(-11.68)          // -12
Math.floor(-11.5)            // -12
 
 
 
 
 
 
 
 
 
 
 
 

Math.round(),Math.ceil(),Math.floor()的更多相关文章

  1. Oracle中trunc函数、round 函数、ceil函数和floor函数的使用

    Oracle中trunc函数.round 函数.ceil函数和floor函数的使用 1.1trunc函数处理数字 trunc函数返回处理后的数值,其工作机制与ROUND函数极为类似,只是该函数不对指定 ...

  2. Math.Round四舍六入五取偶Math.Ceiling只要有小数都加1Math.Floor总是舍去小数

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

  3. Oracle-trunc函数、round 函数、ceil函数和floor函数---处理数字函数使用

    0.round函数 按照指定小数位数进行四舍五入运算. SELECT ROUND( number, [ decimal_places ] ) FROM DUAL #number : 待处理数值  de ...

  4. Math.floor,Math.ceil,Math.rint,Math.round用法

    一.Math.floor函数讲解 floor原意:地板.Math.floor函数是求一个浮点数的地板,就是求一个最接近它的整数,它的值小于或等于这个浮点数.看下面的例子: package com.qi ...

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

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

  6. Number(),parseInt(),parseFloat(),Math.round(),Math.floor(),Math.ceil()对比横评

    首先,这些处理方法可分为三类. 1,只用来处理数字取整问题的:Math.round(),Math.floor(),Math.ceil(): 2,专门用于把字符串转化成数值:parseInt(),par ...

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

    以前经常在代码中看到Math.round.parseInt.Math.floor和Math.ceil这四个函数,虽然知道结果都可以返回一个整数,但是对他们四者的区别还是不太清楚,今天就做一个小结. 一 ...

  8. js中Math.round、parseInt、Math.floor和Math.ceil小数取整小结【转】

    [摘要:之前常常正在代码中看到Math.round.parseInt.Math.floor战Math.ceil那四个函数,固然晓得效果皆能够返回一个整数,然则对他们四者的差别照样没有太清晰,本日便做一 ...

  9. Math类的三个方法比较: floor() ceil() round()

    public class Test { public static void main(String[] args) { double d1 = 3.4, d2 = 3.6; //正数 double ...

  10. js中Math.round、parseInt、Math.floor和Math.ceil小数取整总结(转)

    js中Math.round.parseInt.Math.floor和Math.ceil小数取整总结 Math.round.parseInt.Math.floor和Math.ceil 都可以返回一个整数 ...

随机推荐

  1. ReactiveX 学习笔记(23)RxCpp

    RxCpp RxCpp 是 ReactiveX 的 C++ 语言实现. 下载 RxCpp $ git clone --recursive https://github.com/ReactiveX/Rx ...

  2. NLTK 统计词频

    import nltk Freq_dist_nltk = nltk.FreqDist(list) for k,y in Freq_dist_nltk: print str(k),str(y)

  3. tar --exclude排除指定目录打包

    ----before-upgrade./ --exclude=apache-tomcat-/logs --exclude=apache-tomcat-/work 注意,--exclude后面跟路径名称 ...

  4. Error configuring application listener of class org.springframework.web.util

    解决方案: 1.打开工程属性对话框,到Deployment Assembly页面,点击Add 2. 选择Jave Build Path Entries 3. 把程序用于的Library加入进来 4.重 ...

  5. git 添加分支并与远程连接

    今天由于项目需要,要改版,为了不影响当前网站,所以用分支来管理 首先,在本地添加分支dev git checkout -b dev 提交远程,让同事拉取这个分支,我是直接push了,推到远程. 同事在 ...

  6. AC自动机——1 Trie树(字典树)介绍

    AC自动机——1 Trie树(字典树)介绍 2013年10月15日 23:56:45 阅读数:2375 之前,我们介绍了Kmp算法,其实,他就是一种单模式匹配.当要检查一篇文章中是否有某些敏感词,这其 ...

  7. 查看linux中tcp连接数

    一.查看哪些IP连接本机 netstat -an 二.查看TCP连接数 1)统计80端口连接数netstat -nat|grep -i "80"|wc -l 2)统计httpd协议 ...

  8. 利用maven将项目打包成一个可以运行的独立jar包

    目标:希望把Java项目打包成一个完整的jar包,可以独立运行,不需要再依赖其他jar包. 我们在用eclipse中mvn创建mvn项目的时候,选择非webapp,会默认的以jar打包形式,如下图: ...

  9. Fefora 14 源

    默认的源不能用,需要用下边的源路径. [fedora] name=Fedora $releasever - $basearch failovermethod=priority #baseurl=htt ...

  10. CentOS6.5在虚拟机中安装

    只有一点,先建虚拟机,再选择iso镜像安装,注意,安装路径不能有中文空格之类的. CentOS6.5 64位下载链接 链接:https://pan.baidu.com/s/1d6zp5LtKtkL8I ...