Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is Infinity / Infinity not 1?

If

Infinity === Infinity
>> true

and

typeOf Infinity
>> "number"

then why is

Infinity / Infinity
>>NaN

and not 1?

like image 489
Jayne Mast Avatar asked Sep 15 '11 09:09

Jayne Mast


2 Answers

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.)

like image 127
Marcelo Cantos Avatar answered Sep 17 '22 23:09

Marcelo Cantos


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 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). (edit: as I said, I'm not a mathematician ;)).

like image 22
Felix Kling Avatar answered Sep 21 '22 23:09

Felix Kling