zoukankan      html  css  js  c++  java
  • JS之Math用法

    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));
        
    }

    本文为博主原创文章,欢迎转载,但转载须注在明显位置注明【博客地址】和【原文地址】,否则将追究法律责任。http://www.cnblogs.com/cxd1008
  • 相关阅读:
    property里的参数
    property关键字的理解
    OC与C语言的几点区别
    C语言学习心得
    QQ第三方<接口>
    为什么选择Redis
    版本控制器
    url传参及重定向
    开发的四个环境
    Paxos分析
  • 原文地址:https://www.cnblogs.com/cxd1008/p/6372452.html
Copyright © 2011-2022 走看看