Re: Machine epsilon
I am forwarding the actual code for macheps kindly submitted by Eric:
---------- Begin Forwarded Message ----------
>From stahlber "-at-" hydrogen.mps.ohio-state.edu Tue Jun 25 11:11:02 1991
>Date: Tue, 25 Jun 91 11:15:22 EDT
>From: Eric Stahlberg <stahlber "-at-" hydrogen.mps.ohio-state.edu>
>To: jkl "-at-" ccl.net
>Subject: Re: Machine epsilon
The machine epsilon can easily be found with the following program:
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+D0
GOTO 100
200 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+D0
GOTO 300
400 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+D0
GOTO 500
600 PRINT *,'MACHINE PRECISION R16 IS GT :', TOL16
*MDC*ENDIF
STOP
END
I have used it to determine the machine precision for various machines
and word sizes.
Eric Stahlberg
OSU Chemistry
----------- End Forwarded Message -----------