JavaScript
Math.floor
() 函数
Math.floor
(x)
-- 返回小于等于数字参数的最大整数,对数字进行下舍入
-
floor
,中文"底"的意思
- 引用网址:http://www.dreamdu.com/javascript/Math.floor
/
floor函数语法
Math
.
floor
(
x
)
;
floor函数参数
floor函数返回值
返回小于等于x的最大整数
floor函数示例
document
.
write
(
Math
.
floor
(
5.99
)
)
;
document
.
write
(
Math
.
floor
(
-
5.99
)
)
;
document
.
write
(
Math
.
floor
(
1.01
)
)
;
document
.
write
(
Math
.
floor
(
-
1.01
)
)
;
结果:
5
-6
1
-2
JavaScript Math.floor
() 函数示例 -- 可以尝试编辑
延伸阅读
- JavaScript Math.ceil()
函数 -- 返回大于等于数字参数的最小整数(取整函数),对数字进行上舍入
分享到:
相关推荐
<SPAN xss=removed>1.Math... 2.Math.floor(num); 参数num为一个数值,函数结果为num的整数部分(返回小于等于n的最大整数)。 Math.floor(num); 参数num为一个数值,函数结果为num的整数部分(返回小于等于n的最大整数
2、Math.ceil(num) – 向上取整,不管小数点后面是多少,哪怕.00001,也会向上进一位。 Math.ceil(25.9); //26 Math.ceil(25.5); //26 Math.ceil(25.1); //26 3、Math.floor(num) – 向下取整,不管小数点后面是...
2.Math.floor(num); 参数num为一个数值,函数结果为num的整数部分。 3.Math.round(num); 参数num为一个数值,函数结果为num四舍五入后的整数。 Math:数学对象,提供对数据的数学计算。 Math.random(); 返回0和1间...
Math.ceil()执行向上舍入,即它总是将数值向上舍入为最接近的整数; Math.floor()执行向下舍入,即它总是将数值向下舍入为最接近的整数; Math.round()执行标准舍入,即它总是将数值四舍五入为最接近的整数; 例如:
1.格式化金钱值 ...2.取整代替正数的Math.floor(),代替负数的Math.ceil() const num1 = ~~ 1.69; const num2 = 1.69 | 0; const num3 = 1.69 >> 0; // num1 num2 num3 => 1 1 1 3.转数值只对null
floor Math.floor() flush SharedObject.flush() focusEnabled MovieClip.focusEnabled font TextFormat.font for for for..in for..in fps Camera.fps fromCharCode String.fromCharCode() ...
1.URI方法 encodeURI()和encodeURIComponent()对URI进行编码 encodeURI()不会对本身属于... //”hello world” 3.Math 对象 Math.E 数学中的e的值 Math.PI π的值 Math.SQRT2 2的平方根 Math.abs(num) num的绝对值 Ma
1.不能显式地创建一个Math对象,直接使用它就可以了;...ceil():始终向上舍入,因此23.75变成24,23.25也是如此; floor():始终向下舍入,因此23.75变成23,23.25也是如此; <html> <meta http-equi
if(smooth > 0) smooth = Math.ceil(smooth); else smooth = Math.floor(smooth); if (IE) bssm.pixelTop+=smooth; if (NS6||NS) bssm.top=parseInt(bssm.top)+smooth lastY = lastY+smooth; setTimeout('makeStatic...
1. Java工具概述 很多人初学程序时,总是在想,那么多的算法该怎么写呀?那么多的数据结构都不熟悉,该怎么实现呀?总是担心英语不好程序学不精通,数学不好写程序无法达到巅峰。学的程序越多,不懂的知识越多。...