I am just getting to learn python as my first language.
In python when I transfer the string type of input() to complex('a+b j') in order to try the addition, the answer of the addition is somehow weird.
I have tried addition of float(), the answer is exactly fit. But why complex weird. how can i fix that.
I have tried this
aComplex = complex("10.11+2j")
bComplex = complex("10.2356+5j")
print(aComplex + bComplex)
aFloat = 10.11
bFloat = 10.2356
print(aFloat + bFloat)
aStrInput = input('a= ')
bStrInput = input('b= ')
aFloatInput = float(aStrInput)
bFloatInput = float(bStrInput)
print(aFloatInput + bFloatInput)
and get
(20.345599999999997+7j)
20.345599999999997
a= 10.11
b= 10.2356
20.345599999999997
thanks.~ so maybe the question can solve my problem Is floating point math broken? i will check it later.() thanks.