Logic behind the hexadecimal number system?

234 Views Asked by At

I am at the point where I understand binary quite well, so I decided to look at the hexadecimal numerical system, but I'm a bit stumped with the logic behind it. For those of you who understand it, you know that numbers 10 through 15 (decimal) are represented by letters A through F respectively within the hexadecimal system. Within the binary system the number 31 is represented as $11111$ or $ 2^0 + 2^1 + 2^2 + 2^3 + 2^4 $. If I try to apply this same logic to the hexadecimal system it doesn't work because $ 1 = 1 $ and $ F = 15 $ but $ 1F = 31 $ based on hexadecimal logic. Could someone explain why this is?

(Sorry if this super basic, I just can't wrap my head around it.)

2

There are 2 best solutions below

0
On BEST ANSWER

It is like positional notation in decimal. Each digit to the left is worth $16$ times more than the one on the right, so $1F_{16}=1\cdot 16+15\cdot 1=31$ For a larger example, note that the third digit is worth $16\cdot 16=256$, so $ABC_{16}=10\cdot 256+11\cdot 16+12=2748$

0
On

You might find it more helpful to compare it to the decimal system you are also familiar with, where the number written as $d_k d_{k-1} \dotsm d_2 d_1 d_0$ (where each $d_i$ is between $0$ and $9$ inclusive) means $10^0 d_0 + 10^1 d_1 + 10^2 d_2 + \dotsb + 10^{k-1}d_{k-1} + 10^k d_k $: in hexadecimal you have $$ h_k h_{k-1} \dotsm h_2 h_1 h_0 \text{ means } 16^0 h_0 + 16^1 h_1 + 16^2 h_2 + \dotsb + 16^{k-1}h_{k-1} + 16^k h_k, $$ where each $h_i$ is now an integer between $0$ and $F$ (or $15$) inclusive.