在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

相关文章:

  • 2022-12-23
  • 2022-01-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-22
猜你喜欢
  • 2022-12-23
  • 2021-11-20
  • 2022-01-31
  • 2022-12-23
  • 2021-09-07
  • 2021-12-07
  • 2021-12-10
相关资源
相似解决方案