- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks a lot for the answer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
test, please disregard
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