Created
January 11, 2016 15:27
-
-
Save vampjaz/b7d768692ace5f867173 to your computer and use it in GitHub Desktop.
Random cs stuff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def bintohex(b): | |
b = str(b);bd = [];hv = [] | |
while b: | |
if len(b) >= 4: | |
a = b[-4:] | |
b = b[:-4] | |
else: | |
a = '0'*(4-len(b)) + b | |
b = '' | |
bd.append(a) | |
for i in bd: | |
tmp = 0;mu = 1 | |
for j in reversed(i): | |
if j=='1':tmp += mu | |
mu *= 2 | |
hv.append(tmp) | |
print ''.join(reversed(['0123456789ABCDEF'[i] for i in hv])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment