      DOUBLE PRECISION FUNCTION S3MACH( XD, BASE, EXP )
C
C S3MACH = XD * BASE**EXP
C
C     (17-JUN-85) -- REVISED TO MAKE OVERFLOW LESS LIKELY
      INTEGER BASE, EXP
      DOUBLE PRECISION TBASE, XD
C
      TBASE = FLOAT(BASE)
      S3MACH = XD
C
      N = EXP
      IF( N .GE. 0 ) GO TO 20
C
      N = -N
      TBASE = 1.0D0/TBASE
C
 20   IF( MOD(N,2) .NE. 0 ) S3MACH = S3MACH*TBASE
      N = N/2
      IF( N .LT. 2 ) GO TO 30
      TBASE = TBASE * TBASE
      GO TO 20
C
 30   IF (N .EQ. 1) S3MACH = (S3MACH * TBASE) * TBASE
      RETURN
C
      END
