zoukankan      html  css  js  c++  java
  • JavaScript中的内置对象-8--3.Math-Math对象的方法-min()- max()- ceil()

    JavaScript内置对象-3.Math(数值)

    学习目标

    1.掌握Math对象的方法:

    min()

    max()

    ceil()

    floor()

    round()

    abs()

    Math.min()

    语法:Math.min(num1,num2,...numN)

    功能:求一组数中的最小值。

    返回值:Number.

    Math.max()

    语法:Math.max(num1,num2,...numN)

    功能:求一组数中的最大值。

    返回值:Number.

    Math.ceil()

    语法:Math.ceil(num)

    功能:向上取整,即返回大于num的最小整数。

    返回值:Number.

    Math.floor()

    语法:  Math.floor(num)

    功能:  向下取整数,返回num的整数部分。

    返回值:Number.

     

    Math.round()

    语法:Math.round(num)

    功能:将整数四舍五入为最接近的整数。

    返回值:Number.

    Math.abs()

    语法:Math.abs(num)

    功能:返回num是绝对值。

    返回值:Number

     

    学习目标

    1.掌握Math对象的random()方法

    2.封装一个求n到m之间的随机整数的函数。

    Math.random()

    语法:  Math.random()

    功能:   返回大于等于0小于1的一个随机数。

    返回值:Number。

    说明:  求n到m之间的随机整数的公式:

    random=Math.floor(Math.random()*(m-n+1)+n);

     

  • 相关阅读:
    程序员开发工作之算法和架构
    iOS开发学习概述及知识整理
    git基本技巧及进阶
    使用命令行工具运行Xcode 7 UI Tests
    技巧集锦2
    Xcode开发小问题集锦
    Xcode 7如何 免费 真机调试iOS应用
    常用shell script 珍藏
    多线程学习7--CountDownLatch
    学习多线程6---栅栏
  • 原文地址:https://www.cnblogs.com/oybb/p/7631170.html
Copyright © 2011-2022 走看看