I'm wondering what are the case to be used for Infinity
under IEEE-754
? Is it used when overflow (positive infinity) or underflow (negative infinity) occurs?
The infinity values are returned by some computations, for example -1/0
and Math.log(0)
return -Infinity
.
Symmetrically they can be used in input of computations, for example 2/-Infinity
returns -0
.
Infinities are also produced when the real value is too big for representation, for example Math.exp(999)
or Math.exp(709)+Math.exp(709)+Math.exp(709)
.
But they're also used anytime you need a number greater (or lower) than any other one, or when you want to explicitly refer to an infinity. For example I commonly use numerical ranges (intervals), that is {min, max}
structures and when a range isn't bound I use infinities, like {-Infinity, 3.2}
, which could be noted as ]-∞, 3.2]
in Mathematics.
Be careful though that the support of infinities in the JS ecosystem isn't that great. For example JSON doesn't normally support them (but some libraries help in that matter, like gson or my own parseMore).