JavaScript中Number类型常见误区如何解决


JavaScriptNumberJavaScriptNumber JavaScript Number double JavaScript IEEE 754 JavaScript 3 3.0

3.0===3//true

253-2^{53}253 ~ 2532^{53}253 0 ~ 7ES60o

(function(){
console.log(0o11===011)
})()
//true
//
(function(){
'usestrict';
console.log(0o11===011)
})()
//UncaughtGyntaxError

0x0 ~ 9A ~ F, A ~ F ES60b0B JavaScript Number Number JavaScript Number double 8 64bit IEEE 754 IEEE 754 IEEE 754 V 5.0 101.0 1.01221.01 * 2^21.0122 S=0M=1.01E=2IEEE 754321S8E23M641S11E52MIEEE754 ME1
EEE8 0 ~ 255E110 ~ 2047EIEEE 754E8E12711E10232102^{10}210E1032 10+127=137 10001001EE01E1271023M1E0E1 ~ 1271 ~ 1023M10.xxxxxxx00E1M0SM0NaN 9.0 9.0 1001.0 1.001231.001 *2^31.00123 S=0 M 001 20 0 23 E 3+127=130 10000010 S+E+M0 10000010 001 0000 0000 0000 0000 0000 32 1091567616 JavaScript 64323132231-2^{31}231 ~ 2312^{31}231 JavaScript 0.1+0.2 0.3 IEEE 754 0.10.2 (0.1)10 => (00011001100110011001(1001)…)2
(0.2)10 => (00110011001100110011(0011)…)20.1 0.2 53 IEEE 754 0.1 0001(1001)(1001)(1001)(1001)(1001)(1001)(1001)(1001)(1001)(1001)(1001)(1001)101
+
(0011)(0011)(0011)(0011)(0011)(0011)(0011)(0011)(0011)(0011)(0011)(0011)(0011)01
=
0100(1100)(1100)(1100)(1100)(1100)(1100)(1100)(1100)(1100)(1100)(1100)(1100)111 0.30000000000000004 53 53 0 53 ES6 Number Number.EPSILON 2.220446049250313e-16 Number.EPSILON JavaScript 5e-324 ~ 1.7976931348623157e+308 Number.MIN_VALUE Number.MAX_VALUE JavaScript Infinity -Infinity Infinity

console.log(Number.MAX_VALUE)//1.7976931348623157e+308
console.log(Number.MIN_VALUE)//5e-324
console.log(Number.MAX_VALUE+Number.MAX_VALUE)//Infinity

JavaScript IEEE 754 ECMAScript E -1074 ~ 971 M 52 M 1M 1 ~ 2532^{53}253 JavaScript Number 210742^{-1074}21074 ~ 253+9712^{53+971}253+971 Number.isFinite()ES6 isFinite() trueJavaScript 253-2^{53}253 ~ 2532^{53}253 -9007199254740991 ~ 9007199254740991 Number.MIN_SAFE_INTEGER Number.MAX_SAFE_INTEGER

console.log(Number.MAX_SAFE_INTEGER)//9007199254740991
console.log(Number.MIN_SAFE_INTEGER)//-9007199254740991
console.log(9007199254740991+2)//9007199254740992

900719925474099153053011:154001:3 x(x>53) 1 : 2^(x-53)^ – 1 Number.MAX_SAFE_INTEGER ~ Number.MAX_VALUE 1JS5353 mathjs mathjs

math.config({
number:'BigNumber',
precision:64
});
console.log(math.format(math.eval('0.1+0.2')));//'0.3'
console.log(math.format(math.eval('0.23*0.34*0.92')));//'0.071944'
console.log(math.免费云主机域名format(math.eval('9007199254740991+2')));
//'9.007199254740993e+15'

JavaScriptNumber

相关推荐: Python中的引用和拷贝规律是什么

这篇文章主要讲解了“Python中的引用和拷贝规律是什么”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“Python中的引用和拷贝规律是什么”吧!在C++/Java里,int a = 1就是创建变量为a,赋值为1…

免责声明:本站发布的图片视频文字,以转载和分享为主,文章观点不代表本站立场,本站不承担相关法律责任;如果涉及侵权请联系邮箱:360163164@qq.com举报,并提供相关证据,经查实将立刻删除涉嫌侵权内容。

(0)
打赏 微信扫一扫 微信扫一扫
上一篇 05/09 18:17
下一篇 05/09 18:18

相关推荐