首页 > 网站 > WEB开发 > 正文

JS之Math用法

2024-04-27 15:04:12
字体:
来源:转载
供稿:网友
function Math1() {    //向上舍入    alert(Math.ceil(25.9));    alert(Math.ceil(25.5));    alert(Math.ceil(25.1));}function Math2() {    //向下舍入    alert(Math.floor(25.9));    alert(Math.floor(25.5));    alert(Math.floor(25.1));}function Math3() {    //四舍五入    alert(Math.round(25.9));    alert(Math.round(25.5));    alert(Math.round(25.1));}//从多少到多少的随机数function Math4(start, end) {    var total = end - start + 1;    $("#math4").val(Math.floor(Math.random() * total + start));    }
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表