Add tests for jeb_utils.utils.int_to_bytes

This commit is contained in:
2026-04-02 13:38:59 +02:00
parent 4656874334
commit cee1fb2758
2 changed files with 46 additions and 1 deletions
+2 -1
View File
@@ -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)