If
Infinity === Infinity
>> true
and
typeOf Infinity
>> "number"
then why is
Infinity / Infinity
>>NaN
and not 1?
Beware any assumptions you make about the arithmetic behaviour of infinity.
If ∞/∞ = 1, then 1×∞ = ∞. By extension, since 2×∞ = ∞, it must also be the case that ∞/∞ = 2.
Since it has come up in discussion against another answer, I'd like to point out that the equation 2×∞ = ∞ does not imply that there are multiple infinities. All countably infinite sets have the same cardinality. I.e., the set of integers has the same cardinality as the set of odd numbers, even though the second set is missing half the elements from the first set. (OTOH, there are other kinds of "infinity", such as the cardinality of the set of reals, but doubling the countable infinity doesn't produce one of these. Nor does squaring it, for that matter.)
Because the specification says so:
Division of an infinity by an infinity results in NaN.
I'm not a mathematician, but even from that point of view, having (edit: as I said, I'm not a mathematician ;)).1
as result it does not make sense. Infinities can be different and only because they are equal in JavaScript does not justify treating them as equal in all other cases (or letting the division return 1
for that matter).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With