This commit is contained in:
Erez Louidor 2015-09-23 10:32:56 -07:00
Родитель 0b6b29f9d2
Коммит cdf8b42ae5
1 изменённых файлов: 6 добавлений и 3 удалений

Просмотреть файл

@ -1125,10 +1125,13 @@ class Vtctld(object):
def uint64_to_hex(integer):
"""Returns the hexadecimal representation of integer treated as a 64-bit unsigned integer.
The result is padded by zeros if necessary to fill an 8 character string. Useful for converting
The result is padded by zeros if necessary to fill an 16 character string. Useful for converting
keyspace ids integers.
Example:
uint64_to_hex(1) == "00000001"
uint64_to_hex(0xDEADBEAF) == "DEADBEEF"
uint64_to_hex(1) == "0000000000000001"
uint64_to_hex(0xDEADBEAF) == "00000000DEADBEEF"
uint64_to_hex(0xDEADBEAFDEADBEAFDEADBEAF) raises an out of range exception.
"""
if integer > (1<<64)-1 || integer < 0:
raise Exception('Integer out of range: %d' %d integer)
return "%08X" % integer