Why `divmod(float('inf'), 1) == (float('nan'), float('nan'))`
wxjmfauth at gmail.com
wxjmfauth at gmail.com
Thu Sep 18 03:13:56 EDT 2014
Le jeudi 18 septembre 2014 08:45:21 UTC+2, Marko Rauhamaa a écrit :
> 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.
>
>
Nothing to do with IEEE. It's a pure Python question.
If Python is using its own algorithmics for some "type
of numbers" and at the same time it uses (or it has to use)
a C library with a different algorithmics, conflicts are
expected.
In my previous example, both solutions are valid. The
both solutions at the same time -> problem.
jmf
More information about the Python-list
mailing list