[Python-ideas] Suggestion: Extend integers to include iNaN

David Mertz mertz at gnosis.cx
Sun Sep 30 11:46:10 EDT 2018


On Sun, Sep 30, 2018 at 11:35 AM Chris Angelico <rosuav at gmail.com> wrote:

> On Mon, Oct 1, 2018 at 1:32 AM Steve Barnes <gadgetsteve at live.co.uk>
> wrote:
> > No complex can be converted to float without accessing either the real
> > or imag component.
> Or taking its absolute value, which will return nan if either part is nan.
>

Well, various other operations as well as abs().  Anything that reduces a
complex to a float already... I guess you could argue that behind the
scenest hese functions all access .real and/or .imag.

>>> float(abs(1+1j))
1.4142135623730951
>>> float(cmath.phase(1+1j))
0.7853981633974483
>>> float(cmath.isfinite(1+1j))
1.0



-- 
Keeping medicines from the bloodstreams of the sick; food
from the bellies of the hungry; books from the hands of the
uneducated; technology from the underdeveloped; and putting
advocates of freedom in prisons.  Intellectual property is
to the 21st century what the slave trade was to the 16th.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180930/34b3192c/attachment-0001.html>


More information about the Python-ideas mailing list