mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-31 17:31:36 +00:00
bitcoin: avoid floating point in int_to_hex
This commit is contained in:
parent
d7c5949365
commit
a53dded50f
1 changed files with 1 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue