         Edinburgh IMP77 Compiler - Version 8.4

    1  %begin
    2    %reals %long
    3    
    4    %integer rounds
    5    %real pi = 1.0
    6  
    7    !%on %event 9 %start
    8    !  print string("Cannot open file"); newline
    9    !  %stop
   10    !%finish
   11  
   12    %integer i
   13    
   14    open input(1, "rounds.txt");   ! open file
   15    select input(1)
   16    
   17    read(rounds);
   18    !print string("Rounds = "); write(rounds,0); newline
   19  
   20    close input;                   ! close file
   21  
   22    rounds = rounds + 2;           ! do this outside the loop
   23  
   24    %for i=2, 1, rounds %cycle
   25      %long %real x = -1.0 + 2.0 * (i & 1); ! allows vectorization
   26      pi = pi + (x / (2 * i - 1)); ! double / unsigned = double
   27      !spaces(4); print fl(pi, 16); newline
   28    %repeat
   29  
   30    pi = pi * 4
   31    print fl(pi, 16);              ! print 16 decimal digits of pi
   32    newline
   33    
   34  %endofprogram

   18 Statements compiled
