replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - Reading double precision numbers
forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Reading double precision numbers

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
Emanuele



Joined: 21 Oct 2009
Posts: 78
Location: Bologna (Italy)

PostPosted: Wed Nov 16, 2011 8:04 pm    Post subject: Reading double precision numbers Reply with quote

When reading floating point numbers from a text file, I get slight numeric differences between Win32 and NET configuration.

Please, consider the following piece of code:
Code:

program Test

character(len=10):: a
double precision:: x, y, z
integer:: k

open(unit=10,file='Input.txt',status='old')
read(10,*)a,x,y,z,k
close(10)

open(unit=20,file='Output.txt',status='replace')
write(20,100) a,k,x,y,z
close(20)

100 format(a10,3x,i1,/,3(f24.14,5x))
end


Let the file 'Input.txt' contain the following text:
Quote:

PT128R7 4321.12 654321.12 21.1 9


When compiled in Win32 mode the 'Output.txt' looks like this:
Quote:

PT128R7 9
4321.11999999999990 654321.11999999999539 21.10000000000000


As you can see a slight numeric difference appears.

Instead, when compiled in NET mode, the output is perfect:
Quote:

PT128R7 9
4321.12000000000000 654321.12000000000000 21.10000000000000


I am using FTN95 6.00 and Plato under Windows 7 Pro 64 bit.

Can someone explain this effect?
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8254
Location: Salford, UK

PostPosted: Wed Nov 16, 2011 8:19 pm    Post subject: Reply with quote

With double precision you only get about 15 significant figures.
When you round off, the results are the same.
Back to top
View user's profile Send private message AIM Address
Emanuele



Joined: 21 Oct 2009
Posts: 78
Location: Bologna (Italy)

PostPosted: Wed Nov 16, 2011 9:29 pm    Post subject: Reply with quote

Yes, you are right. I'd just like to understand the different behaviour of the two configurations...
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8254
Location: Salford, UK

PostPosted: Thu Nov 17, 2011 8:52 am    Post subject: Reply with quote

The answer will probably be deep down within the FTN95 input/output library.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group