See answer by @thomas-weller but additionally, the issue boils down to this. Because there are multiple sizes of infinite we run into a problem when subtracting and dividing them.
Setting aside recent proof that some infinite sets thought to be of different size are in fact the the same size (Mathematicians Measure Infinities and Find They’re Equal).
The list of whole numbers is infinite and the list of real numbers is also infinite. However, the list of real numbers between any two adjacent whole numbers is also infinite.
float("inf") does not give a chance to say "this is infinite" vs "this is infinitely infinite" so we don't know which it is. Note I'm going to use two references from here on:
- INF === infinite
- INFINF === infinitely infinite
Now then where does that leave us:
float('inf') == float('inf') ==> True
It seems reasonable that: (INF or INFINF) is equal to (INF or INFINF)
float('inf') + float('inf') == float('inf')
It seems reasonable that: (INF or INFINF) + (INF or INFINF) is equal to (INF or INFINF)
float('inf') * float('inf') == float('inf')
It seems reasonable that: (INF or INFINF) * (INF or INFINF) is equal to (INF or INFINF)
float('inf') - float('inf') == float('inf')
Now we have a bit of a stickler. We conceptually have lots of potential answers. Given float('inf') - float('inf') then 0 is plausible as is -INFINF and INFINF. This result is undefined and as such nan. In fact, as @thomas-weller points out almost any answer might be plausible.
float('inf') / float('inf') == float('inf')
Same issue as above. This result is undefined given that we don't know how "big" any of the float("inf") are.