- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In Compaq Visual Fortran 6.6 (but perhaps also in other Fortran compiler)
the reals b and c defined as
b = a * 0.01
and
c = a / 100.
are different for some values of the real a
The difference is less than the availableaccuracy on a real.
Could someone give me an explanation for this ?
Christian
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
0.01 cannot be defined exactly in binary which is what the computer uses so any calculations based on it will be subject to the error inherrant in this conversion.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok... obviously
Thanks
Christian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello.
We have very good experience with the accuracy of using DOUBLE PRECISION throughout the entire code and also to enable SSE2 calculations. To do this, please compile your code this way:
ifort /fpconstant /QxN (or QxP if you have Pentium4 Prescott)
The /fpconstant option increases the precision of single precision constants to double precision and the /QxN (or /QxP) enables the SSE2 instruction set for accurate (and potentially packed) calculation of 64 bit double precision numbers.
To be even more careful (maybe the compiler options change in the future?), please reqrite your code this way:
double precision a, b, c
b = a * 0.01D0
c = a / 100.0D0
Now the results should not deviate that much I think.
Lars Petter
We have very good experience with the accuracy of using DOUBLE PRECISION throughout the entire code and also to enable SSE2 calculations. To do this, please compile your code this way:
ifort /fpconstant /QxN (or QxP if you have Pentium4 Prescott)
The /fpconstant option increases the precision of single precision constants to double precision and the /QxN (or /QxP) enables the SSE2 instruction set for accurate (and potentially packed) calculation of 64 bit double precision numbers.
To be even more careful (maybe the compiler options change in the future?), please reqrite your code this way:
double precision a, b, c
b = a * 0.01D0
c = a / 100.0D0
Now the results should not deviate that much I think.
Lars Petter

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