Software Archive
Read-only legacy content

cmplx

gmendolambigroup_it
281 Views
I have some problem with the 'cmplx' function:
Why do 'cmplx' and 'dcmplx' give different
answers in this case?

implicit real*8(a-b,d-h,o-z)
implicit complex*16 (c)
read(1,*)a,b
write(6,*)a,b
c1=cmplx(a,b)
c2=dcmplx(a,b)
write(6,*)' cmplx',c1
write(6,*)'dcmplx',c2
end
===================
input (fort.1)
-0.293809357160967 -0.317954183309470

output

-0.293809357160967 -0.317954183309470
cmplx (-0.293809354305267,-0.317954182624817)
dcmplx (-0.293809357160967,-0.317954183309470)

if you explicitly insert:
a=-0.293809357160967
b=-0.317954183309470
into the program then c1=c2=(a,b) correctly.
0 Kudos
1 Reply
Intel_C_Intel
Employee
281 Views
You might find Dave Eklund's article "Perils of Real Numbers (Part I)" in CVF Newsletter VIII to be useful reading - I am looking forward to Part II.

Bear of little brain
0 Kudos
Reply