zoukankan      html  css  js  c++  java
  • 吴裕雄--天生自然 JAVASCRIPT开发学习:Number 对象

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>菜鸟教程(runoob.com)</title>
    </head>
    <body>
    
    <p>整数最多为 15 位。</p>
    
    <button onclick="myFunction()">点我</button>
    
    <p id="demo"></p>
    
    <script>
    function myFunction() {
        var x = 999999999999999;
        var y = 9999999999999999;
        document.getElementById("demo").innerHTML = x + "<br>" + y;
    }
    </script>
    
    </body>
    </html>

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>菜鸟教程(runoob.com)</title>
    </head>
    <body>
    
    <script>
    var x;
    document.write("<p>仅显示17位: ");
    x=12345678901234567890;
    document.write(x + "</p>");
    document.write("<p>0.2 + 0.1 = ");
    x=0.2+0.1;
    document.write(x + "</p>");
    document.write("<p>可以通过乘以10或除以10来计算: ");
    x=(0.2*10+0.1*10)/10;
    document.write(x +"</p>");
    </script>
    
    </body>
    </html>

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>菜鸟教程(runoob.com)</title>
    </head>
    <body>
    
    <script>
    var y = 0377;
    var z = 0xFF; 
    document.write(y + "<br>");
    document.write(z + "<br>");
    </script>
    
    </body>
    </html>

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>菜鸟教程(runoob.com)</title>
    </head>
    <body>
    
    <script>
    var myNumber = 128;
    document.write(myNumber + ' 十进制<br>');
    document.write(myNumber.toString(16) + ' 十六进制<br>');
    document.write(myNumber.toString(8) + ' 八进制<br>');
    document.write(myNumber.toString(2) + ' 二进制<br>');
    </script>
    
    </body>
    </html>

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>菜鸟教程(runoob.com)</title>
    </head>
    <body>
    
    <script>
    myNumber=2;
    while (myNumber!=Infinity){
        myNumber=myNumber*myNumber;
        document.write(myNumber +'<BR>');
    }
    </script>
    
    </body>
    </html>

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>菜鸟教程(runoob.com)</title>
    </head>
    <body>
    
    <script>
    var x = 2/0;
    var y = -2/0;
    document.write(x + "<br>");
    document.write(y + "<br>");
    </script>
    
    </body>
    </html>

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>菜鸟教程(runoob.com)</title>
    </head>
    <body>
        
    <p>一个数字除以一个字符串结果不是一个数字</p>
    <p>一个数字除以一个字符串数字结果是一个数字</p>
    <p id="demo"></p>
    <script>
    var x = 1000 / "Apple";
    var y = 1000 / "1000";
    document.getElementById("demo").innerHTML = isNaN(x) + "<br>" + isNaN(y);
    </script>
    
    </body>
    </html>

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>菜鸟教程(runoob.com)</title>
    </head>
    <body>
        
    <p id="demo"></p>
    <script>
    var y = 1000 / 0;
    document.getElementById("demo").innerHTML = isNaN(y);
    </script>
    
    </body>
    </html>

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>菜鸟教程(runoob.com)</title>
    </head>
    <body>
    <p id="demo"></p>
    
    <script>
    var x = 123;              // x 是一个数字
    var y = new Number(123);  // y 是一个对象
    var txt = typeof(x) + " " + typeof(y);
    document.getElementById("demo").innerHTML=txt;
    </script>
    
    </body>
    </html>

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>菜鸟教程(runoob.com)</title>
    </head>
    <body>
    <p id="demo"></p>
    
    <script>
    var x = 123;              // x 是一个数字
    var y = new Number(123);  // y 是一个对象
    document.getElementById("demo").innerHTML = x===y;
    </script>
    
    </body>
    </html>

  • 相关阅读:
    python struct详解
    python 二维矩阵及转byte知识点
    c# HttpListener拒绝访问
    c# 捕获一般获取不到的异常
    查看dll依赖项
    Javascript 进阶 作用域 作用域链
    【Android进阶】Gson解析json字符串的简单应用
    做web项目时对代码修改后浏览器端不生效的应对方法(持续更新)
    异常Exception in thread "AWT-EventQueue-XX" java.lang.StackOverflowError
    玩转web之json(五)---将表单通过serialize()方法获取的值转成json
  • 原文地址:https://www.cnblogs.com/tszr/p/10944541.html
Copyright © 2011-2022 走看看