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

Marko Rauhamaa marko at pacujo.net
Thu Sep 18 08:45:06 CEST 2014

wxjmfauth at gmail.com:

> In short, a lack of consistency.
>>>> 1e300*1e300
> inf
>>>> exp(1e300)
> Traceback (most recent call last):
>   File "<eta last command>", line 1, in <module>
> OverflowError: math range error

Good point!

Maybe IEEE had some specific numeric algorithms in mind when it
introduced inf and nan. However, I have a feeling an exception would be
a sounder response whenever the arithmetics leaves the solid ground.


More information about the Python-list mailing list