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.

classification
Title: complex arithmetic: strange results with "imag"
Type: behavior Stage:
Components: Versions: Python 3.0, Python 2.5
process
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)
>>> 1-2j.real
1.0
>>> 1-2j.imag
-1.0
>>> 1-4j.imag
-3.0
>>> (1-4j).imag
-4.0
>>>
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
See http://docs.python.org/ref/numbers.html#l2h-16

(I'd close this as not a bug)
msg55942 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2007-09-16 08:19
Exactly.
History
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