2

I'm wondering about following question, if infinity equals infinity (in a computer) and negative infinity equals negative infinity, why does the last sentence of the following snippet return false?

In [2]: math.inf == math.inf
Out[2]: True

In [3]: -math.inf == -math.inf
Out[3]: True

In [4]: (-math.inf) + (math.inf) == (-math.inf) + (math.inf)
Out[4]: False

In [5]: 

I tried with several languages (C++, Javascript and Haskell) and all results are the same. I supposed it is something related to x86_64 architecture, but I'm not sure.

1 Answers1

1

This is what you would hope for the computer to return. As an example, consider x**2 - x. The function is inf-inf as x goes to infinity, but the answer is infinite rather than 0.

Terms like inf - inf are known as indeterminate. The answer can actually be any real number (or \pm infinity)

Seth Rothschild
  • 384
  • 1
  • 14