PROGRAM mixedassign

  IMPLICIT NONE
  REAL :: a = 3.9, b = 0.9, x = 1.3
  INTEGER :: i, j, k

  i = a               ! assign a real to an integer 
  print*, "i = ",i
  j = -b              ! assign a real to an integer 
  print*, "j = ",j
  k = a - b           ! assign a real expression to an integer
  print*, "k = ",k    
  
  a = i
  print*, "a = ",a

!-- integer division: produces an integer result by truncation (toward zero)
  a = 1999/1000
  print*, "a = ",a
  b = -1999/1000
  print*, "b = ",b
  a = 1999.0/1000
  print*, "a = ",a
  a = 1999/1000.
  print*, "a = ",a    

!-- k/2 is computed as integer division, then is promoted to a real and added to x
  k = 5 
  x = x + k/2  
  print*, "x = ",x    

END PROGRAM mixedassign
