!! Barlow and Barnett, Computing for Scientists 1998
!! page 198                 C++ and Fortran 90

! A program that shows some pitfalls od floating point math.

PROGRAM FP_numbers

  ! 1/3+2/3 is not 1    and    0.1 is not 1/10
  
  REAL      :: third = 1.0 / 3.0 , one = 1.0
  REAL      :: twothirds = 2.0 / 3.0
  CHARACTER :: fmt*11 = '(A , E12.7)'
  PRINT *, one, third, twothirds, 0.1, one/10.0 
  PRINT fmt , ' 1./3. + 2./3. - 1. = ' , third + twothirds - one
  PRINT fmt , ' 1./3. + (2./3. - 1.) = ' , third + (twothirds - one)
  IF( 0.1 /= one/10.0 )  PRINT * , &
       ' 0.1 - 1.0/10. = ' , 0.1 - one/10.0

END PROGRAM FP_numbers


