Data update

This commit is contained in:
Ingy döt Net 2024-07-13 15:19:22 -07:00
parent 29a5eea0d4
commit 5c1bb7bfa9
2011 changed files with 35081 additions and 3229 deletions

View file

@ -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