Section Q: The hexadecimal number system
Using Windows Calculator to convert a number to hexadecimal
Open Windows Calculator by clicking Start>All Programs>Accessories>Calculator. Click the “View” menu and select “Scientific”. Type in a number to be converted to hexadecimal. Press F5 on your keyboard and the decimal number will be converted to hexadecimal. Press F6 to convert it back to decimal.
Understanding the hexadecimal number system
Numbers are abstract entities which can be represented in a variety of different ways. Most of us represent numbers using a decimal (base-10) number system - that is, one with 10 different symbols, or digits, to represent all numbers. Our first 10 numbers: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 only require one digit to be represented, but since there are only ten different digits, our eleventh number (10) requires a combination of digits, or symbols, to be represented. The way we do this is by assigning place values - we have a “ones” (100) place, the right-most digit of any number, and “tens” (101) place to the left of that, a “hundreds” (102) place to the left of that, and so on. When we’re used to using the decimal number system, we don’t have to think about the fact that the number 1265, for example, represents a number far larger then the measly number of 4 small digits it takes to represent the abstract 1265. Instead, we intuitively know that the “1” is really 1 thousand (103), the “2” is 2 hundreds (102), the “6” is 6 tens (101), and the 5 is 5 ones (100). In other words, as we count, when we run out of digits (7… 8… 9… ?), we add one into the next place and start over (10… 11… 12…). Using this method, we could create a number system using any number of digits and still be able to represent any number imaginable. Even if we only had 2 digits to work with, we could count: 0… 1… 10… 11… 100… 101… 110… 111… 1000… 1001… 1010… 1011… 1100… 1101… 1110… 1111… and so on. Using a smaller number of different digits requires more of the same digits to be used to represent a single number. The converse, however, is that if we used a number system based on something larger than ten, we would have more digits to work with and each number would be represented with a more efficient use of digits.
The hexadecimal number system has 16 different digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F, in that order. What comes after F? 10 of course! Although F (hexadecimal) is the same number as 15 (decimal), the hexadecimal system has place values in the same way as the decimal system. There’s the ones (160) place, the sixteens (161) place, the two hundred fifty-sixes (162) place, and so on. So why does 10 (hexadecimal) represent the same number as 16 (decimal)? Because you have 1 sixteen and 0 ones, just like having 1 ten and 6 ones.
What’s 1265 (just a random number) in hexadecimal? The first thing to think about is how many places will it take? Does 1265 fit in the ones place of the hexadecimal number system? Are there 16 or more ones in 1265? Yes, so since we only have 16 different digits to put in each place, it must take more than one place. So then let’s look at the sixteens place: are there 16 or more sixteens in 1265? What is 16 16s? It is 256, so yes, there are more, and thus 1265 must take more than 2 places even in hexadecimal. So let’s look at the next place - are there 16 or more 256s in 1265? 16x256 is 4096, so no there are not 16 256s in 1265. That means the number 1265 (decimal) in hexadecimal must only take the ones place, the 16s place, and the 256s place - three places/digits in total. How many whole 256s are there in 1265? 1265/256=4.94140625, so there are 4 whole 256s in 1265. But 4 256s only accounts for 1024, and our number is 1265, so the remaining 241 must be represented in smaller denominations than the 256s. So the next place is the 16s place - how many whole 16s are there in 241? 241/16=15.0625. But how do we represent 15 in a single digit? In hexadecimal the 16th digit is F, so we have 4 256s, and we have “F” 16s. Those 15 (or “F”) 16s only account for 240 of our remaining 241, so we still have 1 left. We must move on to the ones place - how many whole ones go into 1? Exactly one! So since 1 thousand, 2 hundreds, 6 tens, and 5 ones are the same as 4 256s, 15 16s, and 1 one, then 1265 (decimal) must be the same as 4F1 (hexadecimal)!
Another way to think about it is this: Imagine going to a bank that only has dollar bills in denominations of 160 (1), 161 (16), 162 (256), 163 (4096) and so on. They will always give you change in the highest denominations possible, so that they handle the fewest number of bills. If you withdraw $1265, what bills will you get? You will get 4 $256-bills, 15 $16-bills, and 1 $1-bill.
That’s how it works!