zoukankan      html  css  js  c++  java
  • math() 对象

     math()对象

           禁忌:

                      var arr = new array(1,2,3);  

                          math() 不能通过new 构造函数,不能实例化对象;

       math()    这个函数封装了很多的数字计算的常量值和方法:  

     1.math.random();      // 0-1中的随机数,不包含1       =  Excel 中的 rand();

     2.math.ceil(n);          // 向上取整数,       n=数字   // 只要多出一点,就取下一个整数.

                 例子   math.ceil(3.1)     //  返回4  

     3.math.floor(n);        //向下取整,多再多都不要 取当年整数.

                例子   math.floor(3.99)   // 返回 3 

     4.math.round(n);       // 四舍五入 

               例子    math.round(3.8)        //    返回4

               例子    math.round(3.1)        //   返回3      

     5.   n.toFixed(d)   //  数据.toFixed(d)    d为是保留几位    

               例子   var i= 14.894848

                    i.toFixed(3);     //  返回  14.894

    乘方:

    6. mast.pow(底数,幂)           //  比如 底数 为 2  幂为 3     输出为 8 

    7. mast.max(a,b,c,d,e.....)    //  取数据中的最大值 

    8. mast.min(a,b,c,d,e...)       //  取数据中的最小值 

    9. math.max.apply(math,数组);    

     补充:   

                      随机两个数之间的整数(max一个最大值,min一个最小值);

                    Math.floor( Math.rondom()*(max-min+) +min)    内容的 max  与 min 都为数据

  • 相关阅读:
    Python使用SMTP模块、email模块发送邮件
    harbor搭建及使用
    ELK搭建-windows
    ELK技术栈之-Logstash详解
    【leetcode】1078. Occurrences After Bigram
    【leetcode】1073. Adding Two Negabinary Numbers
    【leetcode】1071. Greatest Common Divisor of Strings
    【leetcode】449. Serialize and Deserialize BST
    【leetcode】1039. Minimum Score Triangulation of Polygon
    【leetcode】486. Predict the Winner
  • 原文地址:https://www.cnblogs.com/zxy-web/p/8532886.html
Copyright © 2011-2022 走看看