1 . Math常用方法
ceil() 对小数进行上舍入
Math.ceil( 25.1~9 ); 都返回26; Math.ceil(-25.1~6);都返回-25 *因为 -25要比-25.1~9要大
floor() 对小数进行下舍入
Math.floor ( 25.1~9 );返回25 ; Math.floor(-25.1~9);都返回-26 *因为-26要比-25.1~9 要小
round( ) 把数四舍五入为最接近的数
Math.round(25.1~4);都返回25 ; Math.round(25.5~9);都返回26;
**负数情况下,小数位是5的时候会舍去!!
Math.round(-25.1~5);都返回25
Math.round(-25.6~9);才会都返回26
random() 返回0~1之间的随机数(包括0,不包括1) 应用场景抽奖
Math.pow(底数,几次方 ) 例如:Math.pow(3.3),3的3次方是3*3*3=27
随机的公式: Math.floor(Math.random() * (max - min+1)) + min; max最大值,min最小值