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

Ian Kelly ian.g.kelly at gmail.com
Wed Sep 17 11:35:54 EDT 2014


On Tue, Sep 16, 2014 at 7:12 PM, Terry Reedy <tjreedy at udel.edu> wrote:
> It does not really matter, however, as infinity cannot be 'floored' as
> required for //
>>>>> math.floor(float('inf'))
> Traceback (most recent call last):
> File "<pyshell#21>", line 1, in <module>
> math.floor(float('inf'))
> OverflowError: cannot convert float infinity to integer
>> and hence
>>>>> float('inf') // 1.0
> nan

In C, floor(INFINITY) returns infinity (at least in the implementation
I just tested).


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /