Why `divmod(float('inf'), 1) == (float('nan'), float('nan'))`

cool-RR ram.rachum at gmail.com
Tue Sep 16 23:40:18 CEST 2014


While debugging my code I found that the bug was because I assumed that something like `divmod(float('inf'), 1)` would be equal to `(float('inf'), float('nan'))`, while Python returns `(float('nan'), float('nan'))`. Why does Python make the division result be NaN in this case? `float('inf') / 1` is still `float('inf')`.


Thanks,
Ram.



More information about the Python-list mailing list