On the right you have a decimal-to-hex calculator widget as well as a hex-to-decimal calculator widget. Read on if you would like to see a tutorial on how decimal and hex work

(Don't be scared.)

Imagine that your dollar system only had dollar amounts in powers of 10. So, the only bills it has is $1 = $10^{0}, $10 = $10^{1}, $100 = $10^{2}, and even bigger bills like $1000 = $10^{3} and $10000 = $10^{4}. Notice that the number of zeros at the end of the dolar bill is the same as the exponent on the power of 10.

Now suppose that you want to put $1073 in your pocket, and you want to use as few bills as possible. Well, then you want to use the biggest bills possible. So you use 1×$1000 bill, 0×$100 bill, 7×$10 bills, and 3×$10 bill.

Notice that the number of bills of each size corresponds exactly to the digits in the money you want. $1073 (ONE ZERO SEVEN THREE) is the same thing as ONE $1000 bill, ZERO $100 bills, SEVEN $10 bills, and THREE $1 bills.

Now suppose you took your $1073 to a whole different country, where their $1 is worth just as much as ours. The difference is, everyone in this country was born with sixteen fingers. (Follow me here.) Because of that, their whole number system, and their whole dollar system uses powers of 16 instead of powers of 10. They even use a different dollar symbol, ¤ instead of $. This is weird to us, but completely normal to them. In fact, they make fun of our crossed-out "S" dollar symbol and tiny ten-finger arms.

When you go exchange money in this country, you are going to exchange each $16 for their ¤10. Notice, however, that ¤10 doesn't mean "ten dollars", it means "sixteen" dollars. They just use a funny number system where that digit "1" in the ¤10 represents 16.

More specifically, their bills are in units of

$1 = ¤1 = $16^{0} = ¤10^{0},

$16 = ¤10 = $16^{1} = ¤10^{1},

$256 = ¤100 = $16^{2} = ¤10^{2},

$4096 = ¤1000 = $16^{3} = ¤10^{3},

$65536 = ¤10000 = $16^{4} = ¤10^{4}

So how much of each bill are you going to get when you go to exchange your $1073 into their funky base-16 bills? Well, you can stack your wallet with 1073 ¤1 bills, or you can go like you did before and use as few bills as possible. Pull out your calculator and calculate powers of 16. You can get 4×¤100 bills (totalling ¤400 or $1024), 3×¤10 bills (totalling ¤30 or $48), and 1×¤1 bills (totalling ¤1 or 1). Add up the numbers and you find ¤431 = $1024 + $48 + $1 = $1073.

Now anyone who uses hex knows that hex numbers frequently contain the letters a through f. For example, 3a2 in hex is equivalent to 930 in decimal. That is, ¤3a2 = $930. Why use all those letters?

The answer to that question is actually as simple and logical as that you need one single symbol to represent each number below your standard base. For example, we use base 10, so we need a symbol to represent all the numbers from zero through nine. Those symbols, of course, are 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. Hexadecimal base uses those same symbols for the numbers zero through nine, but it needs additional symbols to represent the numbers ten through fifteen. Why use letters? Because we are already familiar not just with the letters, but what order they go in. a = 10, b = 11, c = 12, d = 13, e = 14, and f = 15.

So, how do we count in base 16?

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1a, 1b, 1c, 1d, 1e, 1f, 20, 21, 22, 23, ..., 97, 98, 99, 9a, 9b, 9c, 9d, 9e, 9f, a0, a1, a2, a3, a4, ..., f7, f8, f9, fa, fb, fc, fd, fe, ff, 100, 101, 102, ...

To get more practice, scroll above to the Decimal to Hex and Hex to Decimal calculator widgets and try some number and letter strings to see what they give you!

comments powered by Disqus