Decimal, Binary, Octal and Hexadecimal Numbers
(Page 1 of 3)
The numbers we are used to using in every-day life are called decimal numbers, where the word decimal refers to the number ten. The reason for this is rather obvious: every digit can take on one of ten values: 0 to 9. Arithmetic performed on decimal numbers is also called base 10 mathematics, because of this orientation around the number 10. (Why is the number 10 the foundation of our normal mathematical system? Hold both hands up and count )
Computer systems, however, dont have fingers or toes; they deal only with binary numbers. Each bit can represent not a value from 0 to 9, but from, well, 0 to 1. A single 0 or 1 value is sufficient for encoding a single fact, such as whether your car currently is using summer tires or snow tires. It's not nearly enough to hold more complex information, such as your bank account balance, or a text document, or a picture of the Yellowstone canyon.
For this reason, larger collections of bits have been defined by computer scientists, such as bytes (octets), words, and so forth. When individual bits are collected into sets in this way, they can be used together to represent larger integers, which are called binary numbers. Since there are only two possible values for each digit, binary numbers are also called base 2 numbers.
A lot of people are intimidated by binary numbers, because at first they seem quite confusing. The key to understanding them is realizing that they are exactly the same as decimal numbers, except that instead of each digit having a value in the range of 0 to 9, each has a value in the range of 0 to 1. For example, when you count in decimal, you go up to 9 in the ones place, and then you need a second place for tens. If you go above 99, you need a third place for hundreds. Each additional place added on the left is a higher power of ten. Binary is the same, except the limit for each place is 1 instead of 9. In binary, you go up to 1 in the ones place, and then need a second place for twos. If you go above 3, you need a third place for fours. Each added place is a subsequent higher power of two, rather than ten.
Thus, where counting in decimal goes 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 and so on, counting in binary goes 0, 1, 10, 11, 100, 101, 110, 111, 1000, 1001, 1010, 1011, 1100, 1101. The concept is identicalyou just need a lot more digits for binary numbers because there are so many fewer values allowed for each digit. For example, the number 13 in decimal is the same as 1101 in binary. How? Well, in decimal, we have a 3 in the ones place, plus a 1 in the tens place, which has a value of 10. This is 3+10=13. In binary, we have a 1 in the ones place, plus a 1 in the fours place, plus a 1 in the eights place, which is 1+4+8 or 13.
To take a more complex example, 211 in decimal is 11010011 in binary. Table 2 shows how the two are equivalent, by adding the values for each binary digit place where there is a 1. Read it from left to right, going top to bottom. Starting in the left-most column, we see that the example number has a 1 in the "128s" place. So we start with a sum of 128. In the next column there is a 1 in the "64s" place, so we add 64 for a running sum of 192. But in the "32s" place the binary digit value is 0, so we don't add 32 to the sum. We continue down to the "ones" place to get the decimal equivalent of the binary number.
As you can see from this, a binary number with N digits can hold up to 2N values. So, a byte, with eight bits, can hold 28 or 256 different values, which are numbered from 0 to 255. A 16-bit word can hold 216 or 65,536 values.
Home - Table Of Contents - Contact Us
The TCP/IP Guide (http://www.TCPIPGuide.com)
Version 3.0 - Version Date: September 20, 2005
© Copyright 2001-2005 Charles M. Kozierok. All Rights Reserved.
Not responsible for any loss resulting from the use of this site.