This is because the IEEE 754 specifications define it like that.
There is however a reasoning for this: the affinely extended real number system extends the real numbers with the two infinities, which gives some more room for calculating with limits. So with this extension a division by zero is not undefined
or NaN
.
Consider that the following is true for positive x:
limx→0(x) = limx→0(-x)
However the following is not true for positive x:
limx→0(1/x) = limx→0(1/-x)
Note how the above comparisons with limit notation map to the comparisons you listed:
0 === -0;// true
1/0 === 1/-0;// false
Secondly, a division always maintains the following invariance: the result is negative if and only when exactly one of the operands is negative.
Both of these considerations give some credence as to why in IEEE 754:
1/0 === Infinity
1/-0 === -Infinity