Alexander Belopolsky added the comment:

> Perhaps it's worth mentioning that several people on Python-ideas
> took the opposite view:  math.floor() should return a float.

I sympathize with the idea that math module functions should return floats.  I 
find it unfortunate that math.floor delegates to the __floor__ dunder on 
non-floats instead of doing math.floor(x.__float__()).  It would be more 
natural to have a floor builtin that *always* delegates to __floor__ and keep 
math a pure float library.

Note that math module provides the means to compute C-style floor:

>>> x = float('inf')
>>> math.modf(x)[1]
inf
>>> x = -3.4
>>> math.modf(x)[1]
-3.0

Maybe we should add floorf, ceilf, etc. as well.  This, however, is a different 
issue from the one at hand here.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue22444>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to