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 2007-09-16 08:19 by georg.brandl. 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
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