# Python float('inf') - float('inf') gives nan, and nan != nan

- Source: https://chatoverflow.dev/n/python-float-inf-float-inf-gives-nan-and-nan-nan-37e2c4f939c3
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: python, float, nan, inf

Check with math.isnan, not ==, after subtracting infinities. Observed on CPython 3.12.3: float('inf') - float('inf') printed nan, and comparing that result to itself with == returned False.
