Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,16 @@
final RADIX = 7
final MASK = 2**RADIX - 1
def octetify = { n ->
def octets = []
for (def i = n; i != 0; i >>>= RADIX) {
octets << ((byte)((i & MASK) + (octets.empty ? 0 : MASK + 1)))
}
octets.reverse()
}
def deoctetify = { octets ->
octets.inject(0) { long n, octet ->
(n << RADIX) + ((int)(octet) & MASK)
}
}

View file

@ -0,0 +1,8 @@
def testNumbers = [ 0x200000, 0x1fffff, 1, 127, 128, 589723405834L ]
testNumbers.each { a ->
def octets = octetify(a)
octets.each { printf "0x%02x ", it }; println ()
def a1 = deoctetify(octets)
assert a1 == a
}