next up previous
Next: Integration Up: Numerical differentiation Previous: Machine

mache.f

          program mache
          implicit none
          real*8 a,b
          integer POW
c         TO DETERMINE `machine epsilon',
c         DEFINE a=1+2^(-POW), AND b=a-1
c         machine epsilon IS THE SMALLEST VALUE OF 2^(-POW)
c         FOR WHICH b .neq. 0
 
          do POW=1,60
           a=1.0+2.0**(-POW)
           b=a-1.0
           if (b .gt. 0.0) then
             write(*,*)" For 2^{-",POW,"}  b = ",b
            else
             write(*,*)" For 2^{-",POW,"}  b=0"
           endif
          enddo
 
           stop
           end

Run this code and its double precision analogue to see what single and double precision zero means.



Bruce Pitman
Wed Oct 11 12:23:54 EDT 1995