global basCvt$
basCvt$ ="0123456789abcdefghijklmnopqrstuvwxyz"
html "
Decimal
To Base
Num
to Dec
"
for i =1 to 10
RandNum = int(100 * rnd(1))
base = 2 +int(35 * rnd(1))
html "
";using("###", RandNum);"
";using("###", base);"
";toBase$(base,RandNum);"
";toDecimal( base, toBase$( base, RandNum));"
"
next i
html "
"
end
function toBase$(b,n) ' b=base n=nmber
toBase$ =""
for i =10 to 1 step -1
toBase$ =mid$(basCvt$,n mod b +1,1) +toBase$
n =int( n /b)
if n <1 then exit for
next i
end function
function toDecimal( b, s$) ' scring number to decimal
toDecimal =0
for i =1 to len( s$)
toDecimal = toDecimal * b + instr(basCvt$,mid$(s$,i,1),1) -1
next i
end function