37 lines
648 B
Plaintext
37 lines
648 B
Plaintext
INCLUDE "D2:REAL.ACT" ;from the Action! Tool Kit
|
|
|
|
PROC Generate(INT value,base REAL POINTER res)
|
|
REAL denom,rbase,r1,r2
|
|
|
|
IntToReal(0,res)
|
|
IntToReal(1,denom)
|
|
IntToReal(base,rbase)
|
|
WHILE value#0
|
|
DO
|
|
RealMult(denom,rbase,r1)
|
|
RealAssign(r1,denom)
|
|
IntToReal(value MOD base,r1)
|
|
RealDiv(r1,denom,r2)
|
|
RealAdd(res,r2,r1)
|
|
RealAssign(r1,res)
|
|
value==/base
|
|
OD
|
|
RETURN
|
|
|
|
PROC Main()
|
|
INT value,base
|
|
REAL res
|
|
|
|
Put(125) PutE() ;clear the screen
|
|
FOR base=2 TO 5
|
|
DO
|
|
PrintF("Base %I:%E",base)
|
|
FOR value=0 TO 9
|
|
DO
|
|
Generate(value,base,res)
|
|
PrintR(res) Put(32)
|
|
OD
|
|
PutE() PutE()
|
|
OD
|
|
RETURN
|