cic-internal-integration/apps/cic-eth/cic_eth/db/util.py

9 lines
177 B
Python
Raw Normal View History

2021-02-01 18:12:51 +01:00
import math
def num_serialize(n):
if n == 0:
return b'\x00'
binlog = math.log2(n)
bytelength = int(binlog / 8 + 1)
return n.to_bytes(bytelength, 'big')