Binary & Hexadecimal Numbering Systems
All computers today deal with numbers in a binary format, either on (1) or off (0). So, if you want to become more familiar with how a computer operates, it is wise to know a little bit about binary and hexadecimal numbers. Almost all of the numbers you see when pertaining to computers deal with bits or bytes (8 bits). Your connection speed when you hook up to the internet is in bits per second (56bps), divide that by eight and you get your througput in bytes per second, the sectors on a disk are seperated into 512 byte units, the ASCII characters are represented by 256 characters (1 byte), the ammount of memory is represented into bytes (4096 kilobytes = 4MB), the display depth is represented in bytes (256 colors is represented with 8 bits per pixel), etc. So you can see how important it is to get a basic understanding of what the relationship between binary and hexadecimal numbers. After you read this essay, hopefully you will get enough of an understanding that you will begin to piece together how and why a computer deciphers the information the way it does.
Position Valued Representation
Position valued representation (PVR) is a system to represent any value with a limited number of symbols. Take the decimal system for example, we can represent any value that we need with only 10 symbols (0....9). In order for us to accomplish this with the decimal system we follow a simple set of rules - the first position to the left of the decimal point is worth 1. After that each digit's position is worth 10 times the position to it's immediate right. Thus once we go through the symbols 0,1...9, we add another digit to the column to the left and start over with the symbols (8,9,10,11).
- 100=1..............Any number to the 0th power is 1
- 101=10............Any number to the 1th power is that number
With the PVR system there are a number of rules that one must follow, wether it is the decimal (base 10), hexadecimal (base 16) or any other base PVR system.
- The number of digits needed for the system is equal to the base. (i.e. decimal (base 10) has 10 digits)
- The value of the largest digit is one less than the base.
- The first position to the left of the "base point" is worth 1. (i.e. the decimal point is the base point of the decimal system.)
- Every other position is worth base times the position value to its immediate right.
All of this is elementary when used with the decimal (base 10) system, but once you use a different base number it may get a little confusing at first. Now, let's take a look at the binary system.
Binary Numbering (Base 2)
Because all computers work with bits, which can only be either on or off, the binary (base 2) system was developed. Even though the binary system follows all of the PVR rules, it is more difficult to understand because there are only 2 digits - 0 and 1. To get a better understanding of the binary system, try to imagine a car odometer that only uses 2 numbers 0 and 1. Instead of going all the way to nine before it flips the next wheel over, it flips the next wheel over after one.
0000 - mile 0
0001 - mile 1
0010 - mile 2
0011 - mile 3
0100 - mile 4
It may be seem pretty basic here, but it isn't when you try to represent larger numbers. Because it is not practical for us to use the binary system, we use the hexadecimal or base 16 system when we need to express binary values.
Hexadecimal Numbering (Base 16)
The hecadecimal system is based on 16 characters, 0 thru 9, then A thru F. Base 16 gets kind of confusing because we are so used to the base 10 system, we tend to cross the two when working with bigger numbers. The most common errors are to assume that the "tens" position is based on 10 instead of 16. Example: 1E is not 10 + 14 = 24, all numbers are based on 16, so it would be 16 + 14 = 30.
Below is a reference chart for all the hexadecimal symbols, along with the equivalent in binary and decimal.
The interesting thing about hexadecimal and binary systems is that all possible values that are expressed in one system, can be exactly expressed in the other system. The reason for this is that 2 is the only prime factor of 16. This may not seem amazing yet, but let's see how you convert binary into Hexadecimal.
Converting from binary to/from hexadecimal
Most computer designs today arrange bits into groups of eight, which of course are called bytes. When these eight bits are grouped by four, the contents of a byte can be expressed as a two digit hexadecimal number. This is true because there are 256 different patterns that can be contained in a byte - 28 = 256 for binary or 162 = 256 for hexadecimal. So converting from binary to hexadecimal and vice versa becomes extremely simple. The only rule you need to remember to convert from hexadecimal to binary is that one hexadecimal digit always poduces four binary digits. Because of this rule, there is a one to one relationship between a hexadecimal digit and a grouping of four binary digits. When converting from a binary to hexadecimal, always to remember to start 'grouping' the binary digits from the left, and add any leading zeroes you may need if you don't have enoug digits. So, refering to the chart above, check out these examples:
- Hexadecimal to Binary
- 516 = 01012
- 5A16 = 0101 10102
- A516 = 1010 01012
- A5116 = 1010 0101 00012
- Binary to Hexadecimal
- 0100 00102 = 4216
- 1110 10012 = E916
- 0001 1100 00112 = 1C316
Note that a subscript (XY) represents what base a digit is representing.
Adding and Multiplying Hexadecimal Numbers
Currently, we are not going to go into how to add or multiply hexadecimal numbers here (use a calculator). We will however put up a couple more charts for you to reference in case you need it.