首页 > 编程语言 > 详细

JavaScript原始类型-number

时间:2021-05-15 19:29:38      阅读:16      评论:0      收藏:0      [点我收藏+]
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script type="text/javascript">
        // number
        // 整数,小数,特殊值

        // 整数
        // 十进制 结果:86
        // var num = 86;
        // console.log(num);

        // 八进制 0 ~ 7 结果:56
        // var num = 070;
        // console.log(num);

        // 十六进制 0 ~ 9 a ~ f  结果:31
        // var num = 0x1f;
        // console.log(num);

        // 小数  结果:5.01
        // var num = 5.01;
        // console.log(num);

        // 浮点数的科学计数法  结果:56170000
        // var num = 5.617e7; // 5.617 * 10^7
        // console.log(num);

        // 最大值 结果:1.7976931348623157e+308
        // var num = Number.MAX_VALUE;
        // console.log(num);

        // 最小值 结果:5e-324
        // var num = Number.MIN_VALUE;
        // console.log(num);

        // 正无穷 结果:Infinity
        // var num = Number.POSITIVE_INFINITY;
        // console.log(num);

        // console.log(3 < 2); // 返回的结果是false
        // var num = Number.POSITIVE_INFINITY * 1.1;
        // console.log(num); // 返回的结果是Infinity
        // console.log(num > Number.POSITIVE_INFINITY);// 返回的结果是false
        // console.log(isFinite(num)); // 返回的结果是false        
        
        // num = 5;
        // console.log(isFinite(num));// 返回的结果是true

        // NaN
        // var num = NaN;
        // console.log(num); // 返回的结果是NaN
        // console.log(num == NaN);// 返回的结果是false
        // console.log(isNaN(num));// 返回的结果是true
    </script>
</body>
</html>

JavaScript原始类型-number

原文:https://www.cnblogs.com/Friday1/p/14772002.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!