A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2008-January/076538.html below:

[Python-Dev] trunc()

[Python-Dev] trunc() [Python-Dev] trunc()Christian Heimes lists at cheimes.de
Sat Jan 26 23:23:40 CET 2008
Jeffrey Yasskin wrote:
> This interpretation implies that complex should provide __float__() to
> return the non-imaginary portion of a complex number. Is that what you
> intend?

No, please don't. If somebody wants to implement __float__ for complex
numbers please define it as hypot(complex) / sqrt(c.real**2 + c.img**2).

In my opinion float(complex) does do the most sensible thing. It fails
and points the user to abs().

>>> float(complex(1,1))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: can't convert complex to float; use abs(z)
>>> abs(complex(1,1))
1.4142135623730951

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4