! Metodos Numericos y Simulaciones en Astrofisica
! FCEFN - UNSJ, 2010
!
! ejemplo 1
!
! diferencias en precision
!
!
program eje1
implicit none
  integer :: i
  integer, parameter ::p=selected_real_kind(24,200)
  real :: valr,a,b,c
  real*8 :: vald,cdoble,v1,v2,vv
  real(p):: valp

!  valr=4.*atan(1.)
!  vald=4.d0*datan(1.d0)
!  valp=4._p*atan(1._p)

  a=0.1
  b=0.00003
  c=a+b
  cdoble=dble(c)
  
  v1=0.9999000049998333d0
  v2=0.9999990000005000d0
  vv=v1-v2
  valr=1.
  vald=1.d0
  valp=1._p
  
  write(*,*)precision(valr), range(valr), tiny(valr),radix(valr)
  write(*,*)precision(vald), range(vald), tiny(vald),radix(vald)
  write(*,*)precision(valp), range(valp), tiny(valp),radix(valp)
  write(*,*)a,b,c,cdoble,abs(c-0.10003),dabs(cdoble-0.10003d0)
  write(*,*)v1,v2,vv,dabs(vv+0.0000989950006667)
  
  pause

  open(7,file='eje1b.out')
 
  do i=1,1000
    write(7,'(g15.8,g23.16,g27.20)')valr,vald,valp
    write(*,'(g15.8,g23.16,g27.20)')valr,vald,valp
    valr=valr/7.
	vald=vald/7.d0
	valp=valp/7._p
  enddo
  close(7)
end program eje1
