<script> /*Math对象用于执行数学任务 * 1.随机数:Math.random():默认执行0-1之间的随机数 * */ // let random=parseInt(Math.random()*11);//0-10之间的随机数 // document.write(random); /*40-60*/ //公式:(Math.random()*(大-小)+小) let a=parseInt(Math.random()*(60-40)+41); document.write(a); //四舍五入取整:round() console.log(Math.round(25.6));//26 //向下取整 floor() console.log(Math.floor(36.8));//36 //向上取整 celi(); console.log(Math.ceil(29.8));//30 //绝对值abs() console.log(Math.abs(-35));//35 </script>
Math对象用于执行数学任务
最新推荐文章于 2022-09-26 02:30:37 发布