program typen_in_fortran
implicit none
! integer kind ===========================================================
integer (kind=1) :: i1=1
integer (kind=2) :: i2=1
integer (kind=4) :: i4=1
integer (kind=8) :: i8=1                     ! jede Zeile einzeln
                                             ! besprechen
!write(*,*) i1,i2,i4,i8
!write(*,*) huge(i1),huge(i2),huge(i4),huge(i8)
!write(*,*) huge(i1)+1,huge(i2)+1,huge(i4)+1,huge(i8)+1
!write(*,*) kind(i1),kind(1)
!write(*,*) huge(i1)+1_1,huge(i2)+1_1,huge(i4)+1,huge(i8)+1
!write(*,*) range(i1),range(i2),range(i4),range(i8)
!
!do i1=2,20
!   write(*,*) i1," Stellen benoetigen kind ", selected_int_kind(i1)
!   end do

! real kind ==============================================================
real (kind=4) :: r1
real (kind=8) :: r2
real (kind=16) :: r3

write(*,*) huge(r1), tiny(r1), epsilon(r1), precision(r1)
write(*,100) huge(r1), tiny(r1), epsilon(r1), precision(r1)
write(*,*) huge(r2), tiny(r2), epsilon(r2), precision(r2)
write(*,200) huge(r2), tiny(r2), epsilon(r2), precision(r2)
write(*,*) huge(r3), tiny(r3), epsilon(r3), precision(r3)
write(*,300) huge(r3), tiny(r3), epsilon(r3), precision(r3)
write(*,*) "Standardkinds: ", kind(1), kind(1.0),kind(.true.)
r1=tiny(r1)
write(*,*) 1.0+epsilon(1.0),1.0+epsilon(1.0)*0.9,1.0+epsilon(1.0)*0.8,1.0+epsilon(1.0)*0.5 
do i1=1,20
   r1=r1*0.8_4
   write(*,*) i1,r1
   end do
write(*,*) tiny(r3)*0.99_16
100 format(" kind=4"/3e /i/)
200 format(" kind=8"/3e /i/)
300 format(" kind=16"/3e /i/)
! huge          groesster darstellbarer Wert
! tiny          kleinster positiver darstellbarer Wert
! epsilon       kleinster Wert mit 1+eps>1
! precision     Anzahl der darstellbaren Dezimalstellen

end program typen_in_fortran
