[Python-ideas] Fwd: Make `float('inf') //1 == float('inf')`
MRAB
python at mrabarnett.plus.com
Thu Sep 18 17:40:41 CEST 2014
On 2014-09-18 16:20, Ian Cordasco wrote:
> On Thu, Sep 18, 2014 at 9:09 AM, Petr Viktorin <encukou at gmail.com> wrote:
>> On Thu, Sep 18, 2014 at 3:38 PM, Ian Cordasco
>> <graffatcolmingov at gmail.com> wrote:
>>>
>>> On Sep 18, 2014 2:31 AM, "Petr Viktorin" <encukou at gmail.com> wrote:
>>>>
>>>> For the record, this gives inf in Numpy.
>>>>
>>>> >>> import numpy
>>>> >>> numpy.array(float('inf')) // 1
>>>> inf
>>>>
>>>> AFAIK this and http://bugs.python.org/issue22198 are the only
>>>> differences from Python floats, at least on my machine.
>>>
>>> That's an interesting bug report and it's significantly different
>>> (mathematically speaking) from the discussion here. That aside, I have to
>>> wonder if numpy has its own way of representing infinity and how that
>>> behaves. I still maintain that it's least surprising for float('inf') // 1
>>> to be NaN. You're trying to satisfy float('inf') = mod + 1 * y and in this
>>> case mod and y are both indeterminate (because this is basically a
>>> nonsensical equation).
>>
>> Well, in `x = y // a`, as y tends towards infinity, x will also tend
>> towards infinity, though in discrete steps. Yes, you get an
>> indeterminate value, but one that's larger than any real number.
>
> Sorry? If you've studied mathematics you'd know there's no discrete
> value that is the same as infinity.
[snip]
He didn't say that infinity was a discrete value, he said that x will
tend towards infinity in discrete steps.
More information about the Python-ideas
mailing list