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/2007-January/070758.html below:

[Python-Dev] compex numbers (was Floor Division)

[Python-Dev] compex numbers (was Floor Division) [Python-Dev] compex numbers (was Floor Division)Jim Jewett jimjjewett at gmail.com
Tue Jan 23 20:47:26 CET 2007
Tim Peters wrote:

>  complex_new() ends with:

>  	cr.real -= ci.imag;
>  	cr.imag += ci.real;

> and I have no idea what that thinks it's doing.  Surely this isn't intended?!:

I think it is.  python.org/sf/1642844 adds comments to make it less unclear.

>  >>> complex(complex(1.0, 2.0), complex(10.0, 20.0))
>  (-19+12j)

>  WTF?

    >>> help(complex)
    Help on class complex in module __builtin__:

    class complex(object)
     |  complex(real[, imag]) -> complex number
     |
     |  Create a complex number from a real part and an optional imaginary part.
     |  This is equivalent to (real + imag*1j) where imag defaults to 0.

If "real" and "imag" are themselves complex numbers, then normalizing
the result will move the imaginary portion of the "real" vector into
the imaginary part and vice versa.

Note that changing this (to discard the imaginary parts) would break
passing complex numbers to their own constructor.

    >>> a=complex(1,2)
    >>> b=complex(a)
    >>> a==b
    True

-jJ
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