bitcoin: avoid floating point in int_to_hex
This commit is contained in:
@@ -60,7 +60,7 @@ def int_to_hex(i: int, length: int=1) -> str:
|
||||
if not isinstance(i, int):
|
||||
raise TypeError('{} instead of int'.format(i))
|
||||
range_size = pow(256, length)
|
||||
if i < -range_size/2 or i >= range_size:
|
||||
if i < -(range_size//2) or i >= range_size:
|
||||
raise OverflowError('cannot convert int {} to hex ({} bytes)'.format(i, length))
|
||||
if i < 0:
|
||||
# two's complement
|
||||
|
||||
Reference in New Issue
Block a user