Cisco Networking: Converting Base 2 (Binary) to Base 10 (Decimal)
Even though you might not think so, binary to decimal conversions are quite easy. A binary number like 10010011 is just like the Base 10 number system, except that each number represents a different column, not 1, 10, 100, 1,000, and so on. These binary numbers represent 1, 2, 4, 8, 16, 32, 64, and 128.
Unlike the decimal system in which you have values from zero to nine in each column, with binary, you have only a zero or one in each column. If you start with a one in binary, it will be in first column; if you add another one to that value, you would add one to the first column.
Because that exceeds the highest value for the one’s column, you would put a zero in the one’s column and carry a one over to the second column (or the two’s column). So in binary, 1+1=10, just like the joke, “There are 10 types of people in the world, those that understand binary and those that do not.”
The following table shows you the conversions. If you look at the decimal values, you simply need to total them to get the decimal value of 11010011, or 128 + 64 + 16 + 2 + 1, or 211. You may become good enough to do that in your head.
The tough part for many people is going the other way. As a decimal, 215, think of the binary conversion this way: The following table shows how to convert a base 10 number to a binary number; for simplicity, the chosen numbers that will result in an answer of eight bits or less.
|Column Value||Decimal||Compared to Column Value||Resulting Action||Binary|
|128||215||Less than 256 but more than 128||Mark 1 for the 128 column and then subtract 128 from 215||1|
|64||87||More than 64||Mark 1 for the 64 column then subtract 64 from 87||1|
|32||23||Less than 32||Mark a 0 for the 32 column||0|
|16||23||More than 16||Mark a 1 for the 16 column and then subtract 16 from 23||1|
|8||7||Less than 8||Mark a 0 for the 8 column||0|
|4||7||More than 4||Mark a 1 for the 4 column and then subtract 4 from 7||1|
|2||3||More than 2||Mark a 1 for the 2 column and then subtract 2 from 3||1|
|1||1||Equal to 1||Mark a 1 for the 1 column||1|
By going through the zeros and ones from top to bottom, the final binary number is 11010111. A zero is given to any position where that number is not present. Not quite as easy as the other way, but still not terribly complicated. If you work through a few numbers, you may find that it does not take long to figure out.
If you want some practice doing binary/decimal conversions quickly and in your head, give some of the Cisco training games a shot, which are available at Cisco Learningnetwork Games. One game that is good for binary to decimal conversion (and vice versa) is the Binary Game. This game is a Tetris-like game, , in which you need to fill in the missing numbers to clear a row off-screen. When the screen is full, you lose, so work quickly.