Open
Description
While playing with the complex module I saw certain expressions giving incorrect results .In Python, when an integer
is operated with objects of complex()
class the integer
is implicitly casted to a complex variable with 0
imaginary value.
y = complex(5)+100
print(y)
(lp) C:\Users\kunni\lpython>python try.py
(105+0j)
(lp) C:\Users\kunni\lpython>src\bin\lpython try.py
(5.000000,0.000000)
y = complex(5)*10
print(y)
(lp) C:\Users\kunni\lpython>python try.py
(50+0j)
(lp) C:\Users\kunni\lpython>src\bin\lpython try.py
(0.000000,0.000000)
y = c32(5)-10
print(y)
(lp) C:\Users\kunni\lpython>python try.py
(-5+0j)
(lp) C:\Users\kunni\lpython>src\bin\lpython try.py
(5.000000,-0.000000)
Metadata
Metadata
Assignees
Labels
No labels