zoukankan      html  css  js  c++  java
  • Math对象

    Math对象没有构造函数,是一个固有的对象,这是它与Date,String对象的区别

    Math的相关函数全部为静态函数,应该直接调用

    Math三角函数与属性

    Math.sin() -- 返回数字的正弦值
    Math.cos() -- 返回数字的余弦值
    Math.tan() -- 返回数字的正切值
    Math.asin() -- 返回数字的反正弦值
    Math.acos() -- 返回数字的反余弦值
    Math.atan() -- 返回数字的反正切值
    Math.atan2() -- 返回由x轴到点(x,y)的角度(以弧度为单位)
    Math.PI 属性 -- 返回圆的周长与其直径的比值(圆周率π),约等于3.1415926
    

      

    Math四舍五入类函数

    Math.abs() -- 返回数字的绝对值
    Math.ceil() -- 返回大于等于数字参数的最小整数(取整函数),对数字进行上舍入
    Math.floor() -- 返回小于等于数字参数的最大整数,对数字进行下舍入
    Math.round() -- 返回数字最接近的整数,四舍五入
    

      

    Math随机数函数

    Math.random() -- 返回0和1之间的伪随机数
    

      

    Math最大最小类函数

    Math.max() -- 返回数个数字中较大的值
    Math.min() -- 返回数个数字中较小的值
    

     Math.max()

    max函数参数

    • a,b,...,x,y -- 为number类型的数字,此值必须大于0

    max函数返回值

    返回数个数值中较大的值

    如果max函数没有给出任何参数,返回-Infinity

    如果有NaN或者非数字类型的参数,返回NaN

    max函数示例

        document.write(Math.max(5,8,6,-5,-6));//8
        document.write(Math.max());//-Infinity
        document.write(Math.max("dreamdu",8)); //NaN
        document.write(Math.max(NaN,0)); //NaN
        document.write(Math.max("-32","-9","-56","-878","-789","-767"));//-9
        document.write(Math.max(-32,-9,-56,-878,-789,-767));//-9
        document.write(Math.max("-32","-9",-56,"-878","-789",-767));//-9
        document.write(Math.max(32,9,56,878,789,767));//878
    

      

      

  • 相关阅读:
    Unity3D脚本修改默认编码界面
    Winform异步初始化UserControl的问题
    Windows API实现移动窗体
    BackgroundWorder控件
    Winform复杂界面异步加载
    TabControl设置选项卡的大小
    VS2010尝试运行项目时出错,无法启动程序
    winform开发-CheckedListBox控件
    tomcat配置https访问
    用户svn密码自定义
  • 原文地址:https://www.cnblogs.com/xiaofenguo/p/6084774.html
Copyright © 2011-2022 走看看