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. .net core 微服务之日志落盘设计

    原文:.net core 微服务之日志落盘设计 目录 1.设计目标 2.日志流程 3.串联请求事务 3.1 请求ID 3.2 处理服务器.服务 3.3 处理接口名 3.4 日志的发生时间 3.5 接口 ...

  2. Django 重写用户模型

    AUTH_USER_MODEL = 'myapp.MyUser' django——重写用户模型 Django内建的User模型可能不适合某些类型的项目.例如,在某些网站上使用邮件地址而不是用户名作为身 ...

  3. echarts Cannot read property 'getAttribute' of null 问题的解决方法

    今天在使用echarts练习官方给的实例的时候,代码没有问题 却总是报错“Cannot read property 'getAttribute' of null” 找了好久的文档没有看明白 ... 最 ...

  4. 100-days: ten

    Title: Emma Watson(艾玛·沃森), Keira Knightley(凯拉·奈特莉) among stars(众多明星之一)  urging(竭力主张,呼吁某事) better pro ...

  5. 项目总结19:layui实现表格渲染、表格搜索、数据获取

    项目总结19:layui实现表格渲染.表格搜索.数据获取 1-参考资料:https://www.layui.com/demo/table/reload.html 2-本次总结的是layui的表格功能, ...

  6. [leetcode]57. Insert Interval插入区间

    Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessa ...

  7. spring多线程

    Spring4.x高级话题(二):多线程 一. 点睛 Spring通过任务执行器(TaskExecutor)来实现多线程和并发编程.使用ThreadPoolTaskExecutor可实现一个基于线程池 ...

  8. sqlserver 更新通过 select 查询出的结果集

    update Babies set BirthOrder =tb.sn from Babies b1, (select ROW_NUMBER() over (partition by familyid ...

  9. 使用虚拟机VM12安装REHL7

    转载https://blog.csdn.net/qq_19467623/article/details/52869108 转载http://www.07net01.com/2016/03/141198 ...

  10. leveldb 源码编译 vs版本

    为什么要windows版本? 因为方便调试跟进 VS的体验真的很不错. 搜索了一段时间才发现GITHUB有windows版本的leveldb 但是使用VS编译也有不少坑 可以下载网络上的其他朋友的版本 ...