 |
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
Emanuele
Joined: 21 Oct 2009 Posts: 78 Location: Bologna (Italy)
|
Posted: Wed Nov 16, 2011 8:04 pm Post subject: Reading double precision numbers |
|
|
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 |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8254 Location: Salford, UK
|
Posted: Wed Nov 16, 2011 8:19 pm Post subject: |
|
|
With double precision you only get about 15 significant figures.
When you round off, the results are the same. |
|
Back to top |
|
 |
Emanuele
Joined: 21 Oct 2009 Posts: 78 Location: Bologna (Italy)
|
Posted: Wed Nov 16, 2011 9:29 pm Post subject: |
|
|
Yes, you are right. I'd just like to understand the different behaviour of the two configurations... |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8254 Location: Salford, UK
|
Posted: Thu Nov 17, 2011 8:52 am Post subject: |
|
|
The answer will probably be deep down within the FTN95 input/output library. |
|
Back to top |
|
 |
|
|
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
|