Converting hex to dec (python3)
Go to solution
Solved by lewdicrous,
Thank you @tikker for showing me where I went wrong, it also helped me troubleshoot another question
Spoiler
Solution: removing toDecimal() from displayDecimal()
Thank you @panther420 for providing a clean way of converting the hexadecimal symbols to integers without using a lot of if-statements
Spoiler
hex_to_dec = { '1' : 1, '2' : 2, '3' : 3, '4' : 4, '5' : 5, '6' : 6, '7' : 7, '8' : 8, '9' : 9, 'A' : 10, 'B' : 11, 'C' : 12, 'D' : 13, 'E' : 14, 'F' : 15 } def toDecimal(h3,h2,h1,h0): dec3 = (hex_to_dec[h3] * 4096) dec2 = (hex_to_dec[h2] * 256) dec1 = (hex_to_dec[h1] * 16) dec0 = (hex_to_dec[h0] * 1) return dec3, dec2, dec1, dec0
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now