随机数

109 阅读1分钟
        /* ceil()对小数进行上舍入	
        Math.ceil(25.5);返回26
        Math.ceil(-25.5);返回-25 */
        
        /* floor()对数进行下舍入
        Math.floor(25.5);返回25
        Math.floor(-25.5);返回-26 */
      
         /* round()把数四舍五入为最接近的数
         Math.round(25.5);返回26
         Math.round(-25.5);返回-25*/
         
       /* random()	返回0.0~1.0之间的随机数
         Math.random() ;
         例如:0.6273608814137365 包括0 不包括1
         
         /* 返回两数之间的小数 不含最大值,含最小值 */
        /* Math.random() * (max - min) + min; */
         /* 返回两数之间的小数 不含最小值,含最大值 */
        /* Math.random() * (max - min) + max; */
        
       /* 两数之间的随机整数 不含最大值,含最小值 */
        /* Math.floor(Math.random()*(max-min)) + min */
        /* 两数之间的随机整数 不含最小值,含最大值 */
        /* Math.floor(Math.random()*(max-min)) + max */
       /* 一个两数之间的随机整数,包括两个数在内  含最大值,含最小值*/
        /* Math.floor(Math.random() * (max - min + 1)) + min; */