# Epsilon

```  Eric Stahlberg's code does one too many divide; the results of his code
are too small by a factor of two.  The test is for a "just noticeable
difference" from 1.0, not a "too small to be noticed difference."
I believe that it should go like this:
PROGRAM MACHPR
REAL*4 R4,TOL4,ZERO4
REAL*8 R8,TOL8,ZERO8
*MDC*IF IBM CRAY
REAL*16 R16,TOL16,ZERO16
*MDC*ENDIF
C
ZERO4=0.0
ZERO8=0.0
R4=1.0
TOL4=R4
100 IF ((R4+TOL4).EQ.R4) GOTO 200
PRINT *,TOL4
TOL4=TOL4/2.0
GOTO 100
200  tol4 = tol4 * 2.0
PRINT *,'MACHINE PRECISION R4 IS GT :', TOL4
R8=1.0
TOL8=R8
300 IF ((R8+TOL8).EQ.R8) GOTO 400
PRINT *,TOL8
TOL8=TOL8/2.0
GOTO 300
400  tol8 = tol8 * 2.0
PRINT *,'MACHINE PRECISION R8 IS GT :', TOL8
*MDC*IF IBM CRAY
R16=1.0
TOL16=R16
500 IF ((R16+TOL16).EQ.R16) GOTO 600
PRINT *,TOL16
TOL16=TOL16/2.0
GOTO 500
600  tol16 = tol16 * 2.0
PRINT *,'MACHINE PRECISION R16 IS GT :', TOL16
*MDC*ENDIF
STOP
END
C code from one of the earlier pseudo-code examples looks like:
main()
{
float eps = 0.00001;
float y = 1.0;
float x;
Again:
x = y + eps;      /* find rough value of eps */
if (x > y)
{
eps = 0.5*eps;
goto Again;
}
eps = 2.0*eps;
Again1:
x = y + eps;       /* find value of eps within 1% */
if (x > y)
{
eps = 0.99*eps;
goto Again1;
}
eps = eps/0.99;
printf("%e",eps);
}
Under Cray UNICOS, there is also a /usr/include/float.h file which
specifies the epsilon limits.
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
Tim Whitley            ((  Internet...twhitley : at : ncsa.uiuc.edu
Cray Research, Inc.     )) Phone......(217) 244-4863
4139 Beckman Institute ((  FAX........(217) 244-2909
405 N. Mathews Avenue   )) "The views presented herein are not those
Urbana, IL 61801       ((   of Cray Research, but are solely my own."
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
```