Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29285 Discussions

Value of epsilon result differs from manual

CHobbs1
New Contributor I
1,534 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 II
1,529 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 II
1,530 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
New Contributor I
1,518 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 II
1,496 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
1,490 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