In js, Number.MAX_VALUE represents the maximum value that can be represented. If this value is exceeded, Infinity will appear, but my calculation below is difficult to understand
(Number.MAX_VALUE+123)==Number.MAX_VALUE //true why?
(Number.MAX_VALUE+Number.MAX_VALUE)==Number.MAX_VALUE //false why?
console.log(5.3e-324) //5e-324 why?
Who understands why this is? Can you explain it?
黄舟2017-06-12 09:28:50
Because 123 is too small to change the high-digit expression
Because Number.MAX_VALUE is large enough to change the expression of high digits
5.3e-324 of .3 is too small
Summary: In many cases, js will have difficulty ensuring the accuracy of floating point number calculations, such as 0.1 + 0.2 != 0.3 // true
曾经蜡笔没有小新2017-06-12 09:28:50
One hundred million plus one, after rounding, it is still one hundred million, which is almost the same truth. It’s not that precise
世界只因有你2017-06-12 09:28:50
It should just represent a numerical value. If the minus sign is separated from the number, it cannot be calculated
我想大声告诉你2017-06-12 09:28:50
In the first example, you just increase your number by a really tiny number: 123 according to 1.79^308 is nothing. So you "lost" some precision: it does not change the number.
In the second one, you exceed the max value, so your number is not a number anymore, it is Infinity.
by Mistalis from stackoverflow
something about Number.MAX_VALUE