Why `divmod(float('inf'), 1) == (float('nan'), float('nan'))`
tjreedy at udel.edu
Thu Sep 18 01:23:51 CEST 2014
On 9/17/2014 10:55 AM, cool-RR wrote:
> Terry, that doesn't really answer the question "why", it just pushes
> it back to the documentation. Is there a real answer why? Why return
> NaN when Inf would make mathematical sense?
IEEE float('inf') and float('nan') are engineering, not math constructs.
I showed that the result is consistent with the math definition.
Another result (including raising) might be also. Many choices
concerting inf and nan are arbitrary and any 'why' can be debated.
Terry Jan Reedy
More information about the Python-list