向下取整floor(),JavaScript进阶篇教程 您所在的位置:网站首页 什么叫向下取整 向下取整floor(),JavaScript进阶篇教程

向下取整floor(),JavaScript进阶篇教程

#向下取整floor(),JavaScript进阶篇教程| 来源: 网络整理| 查看: 265

floor() 方法可对一个数进行向下取整。

语法:

Math.floor(x)

参数说明:

注意:返回的是小于或等于x,并且与 x 最接近的整数。

我们将在不同的数字上使用 floor() 方法,代码如下:

document.write(Math.floor(0.8)+ "") document.write(Math.floor(6.3)+ "") document.write(Math.floor(5)+ "") document.write(Math.floor(3.5)+ "") document.write(Math.floor(-5.1)+ "") document.write(Math.floor(-5.9))

运行结果:

0 6 5 3 -6 -6

 

 



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有