- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
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.
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Bear of little brain
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page