Document Sample

Decimal, Binary, Octal, and Hexadecimal by Mark Doran Lambuth University When an instructor mentions converting between different numbering systems, students usually respond with a stare indicating a type of synaptic short-circuit. Most people say that converting between decimal, binary, octal and hexadecimal is difficult. This is because they don’t understand the simple rules for base conversion. This document will show each of the numbering systems and explain the quick rules for easy conversion. Decimal The decimal numbering system is based on the number 10 which we use every day. The decimal system has ten digits, 0 through 9. It is really arbitrary that we use a base 10 numbering system, but it probably has something to do with the fact that we have ten fingers. Most of us are never made aware that there are other numbering systems until we begin to work with computers. Let’s look at a decimal number example. Take 827 for instance. You’ll notice that this number has three digits. The magnitude of these digits, running from right to left, are based on that numbers base (10 in this case) raised to the power of that digits position, the rightmost digit being at position 0, and the leftmost digit in this case being at position 2. Let’s begin with the first digit, that is, the one on the right. We call this the least significant digit. Its value is 7. 10 to the power of 0 is 1. In fact, any positive integer to the power of 0 is 1. Therefore, no matter what number base we are working with, the least significant digit’s significance is 1. To get the real value of this digit, we must multiply it by 1. It’s still 7, of course, which means that the rightmost digit simply represents a value of 7. Simple enough, right? Now let’s move on to the next digit. This is a 2. And 10 (our base, remember?) to the first power is equal to 10. This digit’s value is 10 * 2, or 20. Now when we add that to our previous digit, we get 20 + 7, or 27. Now we only have one more digit to work with. The final digit is an 8, and it is the 3rd digit (or digit number two, since we begin the count at zero). 10 to the 2nd power is 100. 8 * 100 = 800. We add that to our 27 and get 827, the value of the number. Binary Okay, the number 827 was too easy. Our brains are trained to think in base 10. Base two is referred to as binary. It uses two digits, 0 and 1, called bits (binary digits). In the world of computers, we typically deal with bits in groups of 8, 16, 32, or even 64. For example, a 16-bit computer would process a series of 16 bits at once, repeating the process millions or billions of times per second. Reading a series of bits is very difficult. To make this process easier, they are often displayed in groups of 4 bits. This simple trick will come in very handy later! Let’s look at the binary number 0100 1111 1010 1000. We can use the same method for conversion to decimal that we used for base ten, substituting base 2. Using this method, we conclude that the binary number 0100 1111 1010 1000 equa ls the decimal number 20392. A rule to remember in determining the value of a binary number is to start with the number 1 in the least significant position (position 0) and double it for each position you move to the left. For example, this trick would yield the series 1, 2, 4, 8, 16, 32, 64, 128, 256, …32768 for a 16bit number. Now we can convert a binary number to decimal, but you know that conversions can be a twoway street. How on earth do we convert a decimal number to binary? This side of the street takes a different kind of engine. The binary-to-decimal engine is multiplication, so the decimal- to-binary engine is division. In order to make this engine run smoothly, we must remember the series mentioned above. Let’s look at converting the decimal number 20392 back to binary. Step one is to find the largest number from the binary series that is less than the decimal number being converted. In this case, the number 16384 is the largest number less than 20392. Step two is to divide the decimal number 20392 by 16384. Because of step one, the answer is always 1! 20392 / 16384 is 1 with a remainder of 4008. Because 16384 is represented by a 1 in the 2^14 place, put a 1 there. Now go back to step one and continue the process until the remainder equals zero. Step three is easy. Put a zero in all the blank places in your binary number. All finished! Octal Now that we’ve seen decimal and binary, let’s take a look at octal, or base 8. An octal number system has 8 digits, 0 through 7. Le t’s look at the octal number 247. Using the same methodology as before, we can quickly determine its decimal value. To convert the decimal number 167 back to octal, we simply use a series of the exponentiation of 8. This series would start with 1, 8, 64, 512, etc. Driving down the division side of the street, we can quickly see that we would first divide 167 by 64, yielding 2 with a remainder of 39. We put a 2 in the 8^2 position and repeat the process with the remainder. This quickly gets us back to our octal number 247. Easy, right? Now that we’ve mastered converting binary and octal to decimal, let’s throw a wrench into the works! Hexadecimal Hexadecimal is a base 16 numbering system! This means that we need 16 digits, right? Herein lies the problem. Fortunately, digits are just arbitrary symbols representing some value. For hexadecimal we just use the symbols that have historically been used, which are 0 through 9 and A through F. This gives us the 16 symbols we need! The number A equals the decimal value 10; B equals 11 and so on. Let’s take the hexadecimal number 5A9F as our example Converting from decimal to hexadecimal and back uses the same tricks as before, so I won’t continue to beat that horse here. Other Conversion Tricks So far we’ve only looked at converting between decimal and other bases. What if you need to go directly from binary to hexadecimal or from hexadecimal to octal? There is an easier way to go directly between binary, octal and hexadecimal. Since all these numbering systems are based on a power of 2, let us take a closer look. You may have noticed that the largest single octal digit is 7. This octal digit can be represented by the binary number 111. This means that we can represent any octal digit with exactly 3 bits! Let’s use the same octal number from above, 247. The number 2 is 010, 4 is 100 and 7 is 111. if we put them together, we get 010 100 111. How easy was that? Let’s see how easy it is to go the other way. Take the binary number 0100 1111 1010 1000 and group the bits in groups of 3; 0 100 111 110 101 000. Start at the right and convert each group of 3 bits to its octal number. First we get 000 = 0, 101 = 5, 110 = 6, 111 = 7 and 100 = 4 (you can ignore the leading zero). This gives us the octal number 47650. Have you figured out the trick for hexadecimal yet? Simply group the bits in groups of 4. With four bits we can represent the number 0 through 15 (or F in hexadecimal). Again, let’s look at 0100 1111 1010 1000. Take each group of bits and convert it to its hexadecimal equivalent. We get 0100 = 4, 1111 = F (15), 1010 = A (10), and 1000 = 8. This gives us the number 4FA8. To go the other way, just use 4 bits to represent each hexadecimal digit. Now, put them together into 0100 1111 1010 1000 and you’re finished. Can you see a way to easily convert from octal to hexadecimal and back? First convert to binary! For example: What a journey! You have seen the decimal, binary, octal and hexadecimal numbering systems and how to convert between them. The next time your instructor mentions converting between different numbering systems, you can respond with confidence while your fellow students recover from their synaptic short-circuit! Tables

DOCUMENT INFO

Shared By:

Categories:

Tags:
numbering systems, Numbering System, decimal number, base 10, binary digits, Place Value, decimal to binary, base 2, binary number, How to, large numbers, decimal to hexadecimal, 2 x 2, Artificial Intelligence, octal number

Stats:

views: | 187 |

posted: | 9/11/2009 |

language: | English |

pages: | 6 |

Description:
Easily understanding of all number systems

OTHER DOCS BY abhishekshukla25

Docstoc is the premier online destination to start and grow small businesses. It hosts the best quality and widest selection of professional documents (over 20 million) and resources including expert videos, articles and productivity tools to make every small business better.

Search or Browse for any specific document or resource you need for your business. Or explore our curated resources for Starting a Business, Growing a Business or for Professional Development.

Feel free to Contact Us with any questions you might have.