• JS Math对象


    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Math对象</title>
    </head>
    <body>
        <script>
            document.write(Math.PI) // 圆周率
            document.write("<br/>")
            document.write(Math.SQRT2) // 2 的平方根
            document.write("<br/>")
            //向上取整
            document.write(Math.ceil(3.133)); //4
            document.write("<br/>")
            //向下取整
            document.write(Math.floor(5.324234)) //5
            document.write("<br/>")
            //幂运算
            document.write(Math.pow(4, 2)) //16
            document.write("<br/>")
            //平方根
            document.write(Math.sqrt(4)) //2
            document.write("<br/>")
            //最小值
            document.write(Math.min(1, 2, 3, 4, 5, 6, 7)) //1
            document.write("<br/>")
            //最大值
            document.write(Math.max(1, 2, 3, 4, 5, 6, 7)) //7
            document.write("<br/>")
            //0~1之间的随机数
            document.write(Math.random())
            document.write("<br/>")
            //1~100之间的随机数
            /*  for (var a = 0; a <= 101; a++) {
                  var s = Math.floor(Math.random() * 100) + 1
                  document.write(s + "<br/>")
              }*/
            //Math.round  四舍五入(仅保留整数位)
        </script>
    </body></html>
  • 相关阅读:
    线程的同步之Synchronized的使用
    线程的优先级
    线程的状态和常用操作
    Eclipse设置代码模板Code Template
    Eclipse设置每行代码的长度
    Eclipse设置控制台字体
    Gradle 安装(Windows)
    DSL与GPL
    Windows 新增 Sublime Text3 右键快捷方式
    mvn install 上传 jar 包到Maven仓库
  • 原文地址:https://www.cnblogs.com/001yjk/p/10651816.html
Copyright © 2020-2023  润新知