Data update
This commit is contained in:
parent
29a5eea0d4
commit
5c1bb7bfa9
2011 changed files with 35081 additions and 3229 deletions
|
|
@ -0,0 +1,32 @@
|
|||
func$ encode n b .
|
||||
if n = 0
|
||||
return "0"
|
||||
.
|
||||
while n <> 0
|
||||
r = n mod b
|
||||
n = n div b
|
||||
if r < 0
|
||||
n += 1
|
||||
r -= b
|
||||
.
|
||||
out$ = strchar (r + 48) & out$
|
||||
.
|
||||
return out$
|
||||
.
|
||||
func decode n$ b .
|
||||
if n$ = "0"
|
||||
return 0
|
||||
.
|
||||
for c$ in strchars n$
|
||||
c = strcode c$ - 48
|
||||
tot = tot * b + c
|
||||
.
|
||||
return tot
|
||||
.
|
||||
proc test n b . .
|
||||
h$ = encode n b
|
||||
print n & " -> " & h$ & "_" & b & " -> " & decode h$ b
|
||||
.
|
||||
test 10 -2
|
||||
test 146 -3
|
||||
test 15 -10
|
||||
Loading…
Add table
Add a link
Reference in a new issue