• Math类的round方法小解


        在Math类中有三个关于“四舍五入”的静态方法(ceil,floor,round):

        ① Math.ceil(number)

            向上取整,Math.ceil(11.2) 结果:12              Math.ceil(11.6) 结果:12

                          Math.ceil(-11.2) 结果:-11            Math.ceil(-11.6) 结果:-11

        ② Math.floor(number)

           向下取整, Math.floor(11.2) 结果11              Math.floor(11.6) 结果11

                          Math.floor(-11.2)结果-12             Math.floor(-11.6)结果-12

         ③Math.round(number) = Math.floor(x+0.5)

            ”四舍五入“:Math.round(11.2) 结果11          Math.round(11.6) 结果12

                              Math.round(-11.2) 结果-11      Math.round(-11.6) 结果-12

  • 相关阅读:
    Redis 基本数据类型
    Redis的安装
    Redis介绍
    JavaWeb Servlet
    深入理解JVM1
    JavaWeb Request和Response
    移动端获取屏幕宽度
    meta标签大全(荐)
    网页加载进度条
    每个JavaScript程序员都需要知道的5个数组方法
  • 原文地址:https://www.cnblogs.com/shuaiandjun/p/5428637.html
Copyright © 2020-2023  润新知