c c
c
program number_types
c
c Set parameters giving the kinds for INTEGERs with 2 and 9
c decimal digits.
c
integer, parameter :: int2=selected_int_kind(2)
integer, parameter :: int9=selected_int_kind(9)
c
c
c Set parameters giving the kinds for REALs with 6, 14, and 30
c digits of decimal precision and maximum values of the order
c 10**20, 10**200, and 10**200 respectively
c
integer, parameter :: real6=selected_real_kind(6,20)
integer, parameter :: real14=selected_real_kind(14,200)
integer, parameter :: real30=selected_real_kind(30,200)
c
c
c Establish some variables with specified kinds
c
real ( real6) x,y,z
real (real14) xd,yd,zd
real (real30) xq,yq,zq
integer (int2) ishort
integer (int9) ilong
c
c Ask for the KIND of various variables
c
print *, 'KIND for variable x = ', kind(x)
print *, 'KIND for variable xd = ', kind(xd)
print *, 'KIND for variable xq = ', kind(xq)
c
print *, 'KIND for variable ishort = ', kind(ishort)
print *, 'KIND for variable ilong = ', kind(ilong )
c
c Information on Decimal representation of various variables
c
print *, 'Digits in variable x = ', precision(x)
print *, 'Largest power of 10 for x = ', range(x)
print *, 'Digits in variable xd = ', precision(xd)
print *, 'Largest power of 10 for xd = ', range(xd)
print *, 'Digits in variable xq = ', precision(xq)
print *, 'Largest power of 10 for xq = ', range(xq)
print *, 'Digits in variable ishort = ', range(ishort)
print *, 'Digits in variable ilong = ', range(ilong)
c
c Information on the internal binary representation of
c
print *, 'Binary Digits in variable x = ', digits(x)
print *, 'Largest power of 2 for x = ', maxexponent(x )
print *, 'Binary Digits in variable xd = ', digits(xd)
print *, 'Largest power of 2 for xd = ', maxexponent(xd)
print *, 'Binary Digits in variable xq = ', digits(xq)
print *, 'Largest power of 2 for xq = ', maxexponent(xq)
print *, 'Binary Digits in variable ishort = ', digits(ishort)
print *, 'Binary Digits in variable ilong = ', digits(ilong)
print *,'Word Length (bits) of variable ishort = ',
# bit_size(ishort)
print *, 'Word Length (bits) of variable ilong = ',
# bit_size(ilong)
stop
end
c
c
c