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

Value of epsilon result differs from manual

CHobbs1
Novice
809 Views

All;

I wrote this program:

Real*4 rsingle
Real*8 rdouble
rsingle = epsilon(rsingle)
rdouble = epsilon(rdouble)
Write(6,*)'rsingle = ',rsingle
Write(6,*)'rdouble = ',rdouble

Pause

And got this result:

rsingle = 1.1920929E-07
rdouble = 2.220446049250313E-016
Fortran Pause - Enter command<CR> or <CR> to continue.

The manual entry for epsilon ends with:

Example

If x is of type REAL(4), EPSILON (X) has the value 2 -23.

 

Why is the difference betweeen 2^(-23) and what is written to the screen so big?

All help on this appreciated.  Thank you.

 

0 Kudos
1 Solution
Arjen_Markus
Honored Contributor I
804 Views

Why do you think there is a big difference? The numerical  value of 2^(-23), when written in decimal form (what you get with write(*,*) is approximately 1.1920928955078125e-7. So, apart from a few extra decimals, that is quite the same value.

The only difference I can think of is the form in which these numbers are presented. But that is the presentation, not the actual value.

View solution in original post

0 Kudos
4 Replies
Arjen_Markus
Honored Contributor I
805 Views

Why do you think there is a big difference? The numerical  value of 2^(-23), when written in decimal form (what you get with write(*,*) is approximately 1.1920928955078125e-7. So, apart from a few extra decimals, that is quite the same value.

The only difference I can think of is the form in which these numbers are presented. But that is the presentation, not the actual value.

0 Kudos
CHobbs1
Novice
793 Views
  • My bad.  I typed it out on the calculator wrong and failed to double check it.  Thank you.
  •  
0 Kudos
Arjen_Markus
Honored Contributor I
771 Views

No problem - it happens to al lof us from time to time. One time I tried to solve a problem in a program and I was sure I had it fixed but still got the erroneous behaviour, only to find out an embarrassingly long time later that I had been running an old version ...

0 Kudos
jimdempseyatthecove
Honored Contributor III
765 Views

>>No problem - it happens to al lof us from time to time.

My wife complained to me that I couldn't balance our check register...
... after looking at the numbers I realized I was using base-8 arithmetic.

Jim Dempsey

0 Kudos
Reply