1
1
mirror of https://github.com/wader/fq.git synced 2024-12-28 08:02:28 +03:00

number_to_bytes: Force int to make it work with bigint

This commit is contained in:
Mattias Wadman 2021-08-24 13:44:45 +02:00
parent 1888bb2892
commit 6a8ba315fa

View File

@ -166,6 +166,8 @@ def table(colmap; render):
# convert number to array of bytes
def number_to_bytes($bits):
# TODO: figure out a saner way to force int
def _to_int: (. % (. + 1));
def _number_to_bytes($d):
if . > 0 then
. % $d, (intdiv(.; $d) | _number_to_bytes($d))
@ -173,7 +175,7 @@ def number_to_bytes($bits):
empty
end;
if . == 0 then [0]
else [_number_to_bytes(1 bsl $bits)] | reverse
else [_number_to_bytes(pow(2; $bits) | _to_int)] | reverse
end;
def number_to_bytes:
number_to_bytes(8);