- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
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 kopiert
3 Antworten
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
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.
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Ok... obviously
Thanks
Christian
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
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

Antworten
Themen-Optionen
- RSS-Feed abonnieren
- Thema als neu kennzeichnen
- Thema als gelesen kennzeichnen
- Diesen Thema für aktuellen Benutzer floaten
- Lesezeichen
- Abonnieren
- Drucker-Anzeigeseite