This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: complex arithmetic: strange results with "imag"
Type: behavior Stage:
Components: Versions: Python 3.0, Python 2.5
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, ggenellina, newman
Priority: normal Keywords:

Created on 2007-09-16 07:31 by newman, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg55940 - (view) Author: Nusret BALCI (newman) Date: 2007-09-16 07:31
"imag" returns incorrect results if invoked on a literal number.
Looks like a bug.

>>> 1-2j
>>> 1-2j.real
>>> 1-2j.imag
>>> 1-4j.imag
>>> (1-4j).imag
msg55941 - (view) Author: Gabriel Genellina (ggenellina) Date: 2007-09-16 08:13
Note that there are no complex literals in Python, only imaginary 
literals. 1-4j is an expression, not a literal.
So 1-4j.imag means 1-(4j.imag) = 1-4 = -3

(I'd close this as not a bug)
msg55942 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2007-09-16 08:19
Date User Action Args
2022-04-11 14:56:26adminsetgithub: 45509
2007-09-16 08:19:54georg.brandlsetstatus: open -> closed
nosy: + georg.brandl
messages: + msg55942
resolution: not a bug
2007-09-16 08:13:23ggenellinasetnosy: + ggenellina
messages: + msg55941
2007-09-16 07:31:20newmancreate