         Edinburgh IMP77 Compiler - Version 8.4

    1  %begin
    2  
    3  %ROUTINE DEC10 FRACTION(%REAL R, %INTEGER PLACES)
    4     %RETURN %IF PLACES<=0
    5     PRINTSYMBOL('.')
    6     %WHILE PLACES>0 %CYCLE
    7        R = FRACPT(R)*10.0
    8        PLACES=PLACES-1
    9        PRINTSYMBOL(INTPT(R)+'0')
   10     %REPEAT
   11  %END
   12  
   13  %ROUTINE DEC10 PRINTFL(%REAL R, %INTEGER P)
   14     %INTEGER EXP,SIGN
   15     SIGN=' '
   16     SIGN='-' %AND R=-R %IF R<0
   17     PRINTSYMBOL(SIGN)
   18     %IF R=0 %START
   19        EXP=-99
   20     %ELSE
   21        %IF P<=0 %START
   22           R=R+0.5
   23        %ELSE
   24           R=R+0.5*10\(-P)
   25        %FINISH
   26        EXP=0
   27        EXP=EXP+1 %AND R=R*0.1 %WHILE R >=10.0
   28        EXP=EXP-1 %AND R=R*10.0 %WHILE R< 1.0
   29     %FINISH
   30     PRINTSYMBOL(INT PT(R)+'0')
   31     DEC10 FRACTION(R,P)
   32     PRINTSYMBOL('@'); WRITE(EXP,1)
   33  %END
   34  
   35  %ROUTINE DEC10 PRINT(%REAL R, %INTEGER B,A)
   36     %REAL RM
   37     %CONSTINTEGER MAX INT= 8_377777777777
   38     %INTEGER SIGN
   39     %ROUTINE P(%INTEGER N)
   40        B = B-1
   41        P(N//10) %IF N >= 10
   42        %IF SIGN # 0 %START
   43           SPACES(B-1)
   44           PRINTSYMBOL(SIGN);  SIGN = 0
   45        %FINISH
   46        PRINTSYMBOL(REM(N,10)+'0')
   47     %END
   48     RM=|R|
   49     DEC10 PRINTFL(R, B+A) %AND %RETURN %IF RM> MAX INT
   50     %IF A<=0 %START
   51        RM=RM+0.5
   52     %ELSE
   53        RM=RM+0.5*10\(-A)
   54     %FINISH
   55     %IF B<=0 %THEN SIGN=0 %ELSE SIGN=' '
   56     %IF R<0 %THEN SIGN='-'
   57     P(INT PT(RM));  !THUS ALLOWING FOR -0.1 ETC.
   58     DEC10 FRACTION(RM,A)
   59  %END
   60  
   61  %endofprogram
?DEC10PRINT unused

   59 Statements compiled
