Browse Source
bitcoin: avoid floating point in int_to_hex
3.3.3.1
SomberNight
6 years ago
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
1 changed files with
1 additions and
1 deletions
-
electrum/bitcoin.py
|
|
@ -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 |
|
|
|