Add tests for jeb_utils.utils.int_to_bytes
This commit is contained in:
@@ -64,7 +64,8 @@ def int_to_bytes(n: int, signed: bool = False) -> bytes:
|
||||
:rtype: bytes
|
||||
'''
|
||||
n = int(n)
|
||||
length = (n.bit_length() + 7) // 8
|
||||
signed_term = 1 if signed else 0
|
||||
length = (n.bit_length() + 7 + signed_term) // 8
|
||||
if length == 0:
|
||||
length = 1
|
||||
return n.to_bytes(length, signed=signed)
|
||||
|
||||
Reference in New Issue
Block a user