bitcoin: avoid floating point in int_to_hex

This commit is contained in:
SomberNight 2018-11-26 01:34:23 +01:00
parent d7c5949365
commit a53dded50f
No known key found for this signature in database
GPG key ID: B33B5F232C6271E9

View file

@ -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