码迷,mamicode.com
首页 > Web开发 > 详细

js 16位丢失精度

时间:2020-03-31 23:16:55      阅读:148      评论:0      收藏:0      [点我收藏+]

标签:public   order   javascrip   mono   weight   osi   attach   http   ubuntu   

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <title> new document </title>
  <meta name="generator" content="editplus" />
  <meta name="author" content="" />
  <meta name="keywords" content="" />
  <meta name="description" content="" />
 </head>
 
 <body>
 
<script language="javascript" type="text/javascript">
var numStr = "";
var charNine = "9";
var maxLength = 20;
for (var i=1; i<=maxLength; i++)
{
    numStr += charNine;
    document.write(i, ": Str: ", numStr, " Num: ",parseInt(numStr), "<br />");
}
 
/*
1: Str: 9 Num: 9
2: Str: 99 Num: 99
3: Str: 999 Num: 999
4: Str: 9999 Num: 9999
5: Str: 99999 Num: 99999
6: Str: 999999 Num: 999999
7: Str: 9999999 Num: 9999999
8: Str: 99999999 Num: 99999999
9: Str: 999999999 Num: 999999999
10: Str: 9999999999 Num: 9999999999
11: Str: 99999999999 Num: 99999999999
12: Str: 999999999999 Num: 999999999999
13: Str: 9999999999999 Num: 9999999999999
14: Str: 99999999999999 Num: 99999999999999
15: Str: 999999999999999 Num: 999999999999999
16: Str: 9999999999999999 Num: 10000000000000000
17: Str: 99999999999999999 Num: 100000000000000000
18: Str: 999999999999999999 Num: 1000000000000000000
19: Str: 9999999999999999999 Num: 10000000000000000000
20: Str: 99999999999999999999 Num: 100000000000000000000
*/
</script>
 
 </body>
</html>

  

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <title> new document </title>
  <meta name="generator" content="editplus" />
  <meta name="author" content="" />
  <meta name="keywords" content="" />
  <meta name="description" content="" />
 </head>
 
 <body>
 
<script language="javascript" type="text/javascript">
var numStr = "";
var charNine = "9";
var maxLength = 20;
for (var i=1; i<=maxLength; i++)
{
    numStr += charNine;
    document.write(i, ": Str: ", numStr, " Num: ",parseInt(numStr), "<br />");
}
 
/*
1: Str: 9 Num: 9
2: Str: 99 Num: 99
3: Str: 999 Num: 999
4: Str: 9999 Num: 9999
5: Str: 99999 Num: 99999
6: Str: 999999 Num: 999999
7: Str: 9999999 Num: 9999999
8: Str: 99999999 Num: 99999999
9: Str: 999999999 Num: 999999999
10: Str: 9999999999 Num: 9999999999
11: Str: 99999999999 Num: 99999999999
12: Str: 999999999999 Num: 999999999999
13: Str: 9999999999999 Num: 9999999999999
14: Str: 99999999999999 Num: 99999999999999
15: Str: 999999999999999 Num: 999999999999999
16: Str: 9999999999999999 Num: 10000000000000000
17: Str: 99999999999999999 Num: 100000000000000000
18: Str: 999999999999999999 Num: 1000000000000000000
19: Str: 9999999999999999999 Num: 10000000000000000000
20: Str: 99999999999999999999 Num: 100000000000000000000
*/
</script>
 
 </body>
</html>

js 16位丢失精度

标签:public   order   javascrip   mono   weight   osi   attach   http   ubuntu   

原文地址:https://www.cnblogs.com/nb123/p/12608974.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!