The IEEE-754 standard states that when overflow occurs, the result may evaluate to either Infinity
or MAX_VALUE
. As I've been recommended a few times already I decided to see what ECMAScript standard says about it. I found this under Applying the Additive Operators to Numbers
If the magnitude is too large to represent, the operation overflows and the result is then an infinity of appropriate sign.
But testing it gives MAX_VALUE
instead of Infinity
, why?
Number.MAX_VALUE+100000000 // evaluates to Number.MAX_VALUE
However, this evaluates to Infinity
:
Number.MAX_VALUE+Number.MAX_VALUE // evaluates to Infinity