ITNE2003 Install, Configure, Operate and Troubleshoot Medium-Sized Networks Lab Tutorial – 2 of Lesson - 2 Victorian Institute of technology
To get a good understanding of other number systems, let’s begin with a familiar topic - the base 10 system. In order to represent the base 10 system, we need 10 different symbols. The symbols we use of course are the digits 0 through 9. If we were to write a value using base 10, it would look like the following:
The subscript 10 has been placed on the end of the value so that there is no doubt that we are working with a base 10 value.
Breaking the value apart one digit at a time, the 8 is in the 1s position and is equal to 8 x 10^{0}, or simply 8 x 1 (anything to the 0^{th} power is 1); the 1 is in the 10s position and is equal to 1 x 10^{1}, or 10; the 0 is in the 100s position and is equal to 0 x 10^{2}, or 0 x 100; and the 3 is in the 1000s position and is equal to 3 x 10^{3}, or 3 x 1000. Note that starting on the right, the powers start at 0 and increment by 1 for every place we move to the left.
The binary system or base 2 system uses only 2 symbols - 0 and 1. If we were to write a binary number, it might look like the following:
Starting again with the right-most digit, we have a 1 in the 1s position, or 1 x 2^{0} which is equal to 1 x 1; the next digit 0 is in the 2s position and is 0 x 2^{1}; the next digit 1 is in the 4s position and is equal to 1 x 2^{2} or 1 x 4; the next digit 0 is in the 8s position and is equal to 0 x 2^{3}, or 0 x 8, and so on. Notice how the positions start with 1 on the right-most bit and proceed to double for each next position - 1, 2, 4, 8, 16, 32, 64, 128, and so on. This corresponds to 2^{0}, 2^{1}, 2^{2}, 2^{3}, 2^{4}, 2^{5}, 2^{6}, and 2^{7}.
Thus, the binary number 10010_{2}
is equal to (starting from the left) 16 + 0 + 0 + 2 + 0, or 18 in decimal. The binary number 1011101_{2}
is equal to 64 + 0 + 16 + 8 + 4 + 0 + 1, or 93 in decimal.
The binary number system can generate some pretty long strings of 1s and 0s for relatively small equivalent decimal values. For example, decimal 16492 is equal to binary 100000001101100. Many people and computer systems often like to work with a notation that is more compact but still closely resembles binary. One choice is the base 16 number system, or hexadecimal. Following the same thread of logic, the base 16 number system needs 16 symbols. The first ten symbols can be the common digits 0 through 9, but what to use for the remaining six symbols? We will use the symbols A, B, C, D, E, and F. Thus we use the symbols 0 - F, which are equivalent to the following decimal and binaryvalues:
Hexadecimal |
Decimal |
Binary |
0 |
0 |
0000 |
1 |
1 |
0001 |
2 |
2 |
0010 |
3 |
3 |
0011 |
4 |
4 |
0100 |
5 |
5 |
0101 |
6 |
6 |
0110 |
7 |
7 |
0111 |
8 |
8 |
1000 |
9 |
9 |
1001 |
A |
10 |
1010 |
B |
11 |
1011 |
C |
12 |
1100 |
D |
13 |
1101 |
E |
14 |
1110 |
F |
15 |
1111 |
If we were to write a hexadecimal number as the following:
we would have the following equivalent decimal value: C x 16^{3}, or 12_{10} x 4096; 2 x 16^{2}, or 2 x 256; A x 16^{1}, or 10_{10} x 16; and B x 16^{0}, or 11_{10} x 1. The resulting decimal value would be 49835.
The neat thing about hexadecimal and binary is how easy it is to translate one form into the other. For example, if we have the hexadecimal value C2AB from above, we can easily convert it to binary by simply replacing each hex digit with the corresponding 4-bit binary equivalent. C = 1100_{2}
2 = 0010_{2}
The resulting binary value would be 1100 0010 1010 1011_{2}.
Conversely, to convert a binary value to hexadecimal, simply group the binary number in groups of 4 digits (starting from the right) and convert each 4-digit group into its equivalent hexadecimal value.
For example, the binary value: 111 1000 1010 1001 0011 0101 1100_{2 }equals 78A935C_{16}
We have already seen how to do some number conversions. Binary to hexadecimal and hexadecimal to binary are straightforward. We have also seen how to convert binary to decimal. Start at the right side of the binary number and count in powers of 2. The right-most binary digit is in the 1s position, the next binary digit is in the 2s position, then the 4s position, the 8s position, and so on.
Converting from decimal to binary is also straight-forward. One simple paper and pencil method^{[1]} is to take the decimal number and repeatedly divide it by 2, keeping track of the integer remainder. For example, lets convert the decimal value 57 to binary using this method.
____
28 with a remainder of 1 (now divide 28 by 2)
14 with a remainder of 0
7 with a remainder of 0
Now take all the remainders starting with the last one and write your binary number:
Is this the correct binary value? Check it. The left-most bit equals 32, the next bit equals 16, the next bit equals 8, and the right-most bit equals 1. 32 + 16 + 8 + 1 = 57.
You can also convert decimal to hexadecimal in a similar fashion (repeatedly divide by 16 and keep track of the integer remainders) but it might be easier to convert the decimal number to binary first, then simply convert the binary number to hexadecimal.
[1] There are of course calculators that can do all these conversions. But if the calculator is not handy, you should be able to perform simple conversions either in your head or on paper and pencil.
Assignment Writing Help
Engineering Assignment Services
Do My Assignment Help
Write My Essay Services