Skip to content

Instantly share code, notes, and snippets.

Avatar

i96751414 i96751414

View GitHub Profile
@i96751414
i96751414 / integer_conversion.py
Last active Jun 20, 2019
Automatically convert integers to hex strings
View integer_conversion.py
def bytes_size(value):
if value == 0:
return 1
size = (value.bit_length() + 7) // 8
if value < 0 and not value & (1 << (size * 8 - 1)):
size += 1
return size
def integer_to_hex(value, decimals=0):
You can’t perform that action at this time.