Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Precision

jacques_fontignie
309 Views

I want to write a double precision number to a file and to read it again later.

Precision is very important and I want to get EXACTLY the same value when reading. I use format(...g) but it seems that sometimes the value is not the same. What format option have I to use?

I use formatted files.

Thanks in advance.

Message Edited by jacques.fontignie on 01-31-2006 05:42 AM

0 Kudos
4 Replies
TimP
Honored Contributor III
309 Views
g25.17e3 format is sufficient for maximum precision conversion of IEEE754 double precision. If you don't specify the widths in the format, you leave it up to the implementor of the run-time library. The IEEE standard gives range limits within which the READ of the value converted by WRITE can return the value exactly. Outside that range, you could avoid changes in the least significant bit only by the use of unformatted file.
0 Kudos
jacques_fontignie
309 Views
Thanks a lot for the answer.
0 Kudos
joseph-krahn
New Contributor I
309 Views
But, beware that some variations you see are because the binary form is not exactly the same as the original formatted number, because decimal representations do not map exactly to binary (base 2) values, even for a simple number like 0.1.
0 Kudos
Dayan_S_Intel
Employee
309 Views
test, please disregard
0 Kudos
Reply