         Edinburgh IMP77 Compiler - Version 8.4

    1  %systemstring(127)%fn rtos(%real r,%integer n,m)
    2    %constreal pmax = 2147483647.0
    3    %real y,z
    4    %integer i=0,l,count=0,sign
    5    %string(127) result = ""
    6    !
    7    sign = ' '
    8    sign = '-' %if r < 0
    9    y = |r|+0.5/10.0\{^}m;  !modulus, rounded
   10    %if y > pmax %start
   11      count = count+1 %and y = y/10.0 %until y < 10.0
   12    %finish
   13    z = 1.0
   14    %cycle
   15      i = i+1;  z = z*10.0
   16    %repeat %until z > y
   17    result = result." " %for l = 1,1,n-i;  !l not used before here
   18    result = result.tostring(sign) %unless sign = ' ' %and n <= 0
   19    %cycle
   20      z = z/10.0
   21      l = int pt(y/z)
   22      y = y-l*z
   23      result = result.tostring(l+'0')
   24      i = i-1
   25      %exit %if i+m <= 0
   26      result = result."." %if i = 0
   27    %repeat
   28    result = result."@".itos(count,0) %if count # 0
   29    %result = result
   30  %end;  !rtos
   31  
   32  %endoffile

   31 Statements compiled
