[Python-ideas] Fwd: Make `float('inf') //1 == float('inf')`

Steven D'Aprano steve at pearwood.info
Fri Sep 19 13:13:38 CEST 2014


On Fri, Sep 19, 2014 at 03:13:13AM -0700, Andrew Barnert wrote:
> On Sep 19, 2014, at 2:52, Steven D'Aprano <steve at pearwood.info> wrote:
> 
> > On Thu, Sep 18, 2014 at 03:31:05PM -0400, Alexander Belopolsky wrote:
> > 
> >> I don't think there is any dispute over what math.floor(inf) should return.
> >> POSIX, C99, IEEE and probably many other standards agree that inf should
> >> be returned as long as the resulting type can represent it.
> > 
> > Why don't we add an integer infinity?
> 
> I was thinking the same thing.
[...]
> That does raise the question of whether there should be an int NaN...

Ah, you had to raise that issue! Now it's sure to be rejected! *wink*

An int NAN can and should be considered only when there is a clear need 
for it. Since Python tends to prefer raising exceptions than returning 
NANs, e.g. 0/0 raises, I'm not sure that there are any operations that 
return ints which would benefit from an int NAN.

(Personally, I'd rather get NANs than exceptions, but apparently I'm in 
the minority.)


-- 
Steven


More information about the Python-ideas mailing list