bt3gl a85ed914d3 👾
2023-07-30 21:40:09 -07:00

24 lines
372 B
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# author: bt3gl
def convert_to_hex(num: int) -> str:
hex_chars = "0123456789abcdef"
size = 32
base = 16
if num == 0:
return "0"
if num < 1:
num += 2**size
result = ""
while num:
result += hex_chars[num % base]
num //= base
return result[::-1]