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/2012-October/122326.html below:

[Python-Dev] return type of __complex__

[Python-Dev] return type of __complex__Larry Hastings larry at hastings.org
Mon Oct 22 13:34:26 CEST 2012
On 10/21/2012 09:35 PM, Steven D'Aprano wrote:
> so as far as I can tell, the only way you could accidentally get a
> complex number without expecting one is by exponentiation, either by **
> or the builtin pow. This includes square roots. Exponentiation isn't as
> common as the basic four arithmetic operators, but it is hardly exotic.
>
> Any time you have a non-integer power and a negative base, you will get
> a complex number.

No, only via the builtin pow.

    % python3
    Python 3.3.0 (default, Sep 29 2012, 22:42:55)
    [GCC 4.6.3] on linux
    Type "help", "copyright", "credits" or "license" for more information.
     >>> import math
     >>> pow(-1, 0.5)
    (6.123031769111886e-17+1j)
     >>> -1 ** 0.5
    -1.0
     >>> math.pow(-1, 0.5)
    Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
    ValueError: math domain error
     >>>



//arry/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20121022/e220509c/attachment.html>
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