round函数语法

Math.round(x);

round函数参数

  • x -- 为number类型的数字

round函数返回值

返回x最接近的整数,如果x的小数部分大于等于0.5,返回值是大于x的最小整数,否则round函数返回小于等于x的最大整数

round函数示例

document.write(Math.round(5.8));
document.write(Math.round(5.2));
document.write(Math.round(-5.8));
document.write(Math.round(-5.2));

结果:

6
5
-6
-5

相关文章:

  • 2021-11-19
  • 2021-09-26
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-09
  • 2022-12-23
  • 2021-12-14
  • 2021-07-15
  • 2022-12-23
  • 2021-09-25
相关资源
相似解决方案