The decimal number system is the one that most people are familiar with. It is also called base-10, which means that it consists of ten digits (0-9). The first digit to the left of the decimal point represents ones, or units (100). The second digit is the tens (101), the third digit is the hundreds (102), the fourth digit is the thousands (103), and so on. To the right of the decimal point, the digits are fractional, with the first digit representing tenths (10-1), the second digit hundredths (10-2), the third digit thousandths (10-3), etc. These are shown in the following example:
1,248.32710 = 1 × 103 + 2 × 102 + 4 × 101 + 8 × 100 + 3 × 10-1 + 2 × 10-2 + 7 × 10-3
The subscript 10 indicates that this is a number from the base-10 system, but in normal practice it is omitted, because numbers are assumed to be decimal unless otherwise specified.
Just as the base-10 system has ten digits, the base-2, or binary number system, has two digits--0 and 1. In the decimal system, each place has a value ten times that of the place to the right; in the binary system, the value of each place is twice that of the place to the right. The digit immediately to the left of the binary point represents ones, or units (20), the second represents twos (21), the next fours (22), then eights (23), and so on. To the right of the binary point, the places are 2-1 (1/2, or .5), 2-2 (1/4, or .25), 2-3 (1/8, or .125), etc. These are shown in following example:
1101.1012 = 1 × 23 + 1 × 22 + 0 × 21 + 1 × 20 + 1 × 2-1 + 0 × 2-2 + 1 × 2-3
The octal number system, as the name suggests, has eight digits--0-7. Each place has a value eight times that of the place to the right. The digit immediately to the left of the octal point represents ones, or units (80), the second represents eights (81), the next sixty-fours (82), then five-hundred-twelves (83), etc. To the right of the octal point, the places are 8-1 (1/8, or .125), 8-2 (1/64, or .015625), 8-3 (1/512, or .001953125), etc. For example:
637.258 = 6 × 82 + 3 × 81 + 7 × 80 + 2 × 8-1 + 5 × 8-2
The hexadecimal, or base-16, number system contains sixteen symbols--the digits 0-9, and the letters A-F to represent the values 10-15. Each place has a value 16 times that of the place to the right. The digit immediately to the left of the hexadecimal point represents ones, or units (160), the second represents sixteens (161), the next two-hundred-fifty-sixes (162), then four-thousand-ninety-sixes (163), etc. To the right of the hexadecimal point, the places are 16-1 (1/16, or .0625), 16-2 (1/256, or .00390625), 16-3 (1/4,096, or .000244140625), etc. For example:
2A4.6316 = 2 × 162 + 10 × 161 + 4 × 160 + 6 × 16-1 + 3 × 16-2
This method uses repeated division by 2. When a number is divided by 2, the only possible remainders are 0 or 1. Keep dividing until the quotient becomes 0; the remainders make up the binary number. In this example, 83710 is converted to binary.
Decimal | ÷ 2 | Quotient | Remainder |
---|---|---|---|
837 | ÷ 2 = | 418 | 1 |
418 | ÷ 2 = | 209 | 0 |
209 | ÷ 2 = | 104 | 1 |
104 | ÷ 2 = | 52 | 0 |
52 | ÷ 2 = | 26 | 0 |
26 | ÷ 2 = | 13 | 0 |
13 | ÷ 2 = | 6 | 1 |
6 | ÷ 2 = | 3 | 0 |
3 | ÷ 2 = | 1 | 1 |
1 | ÷ 2 = | 0 | 1 |
Starting from the bottom, list the digits from the remainder column: the result is 11010001012, which equals 83710.
Another method is to create a table, starting at 20, and listing as many powers of 2 as necessary to cover the number being converted; in this case, that is 29, or 51210. If dealing with fractions, list negative powers of 2 to the right of 20.
In the second row, convert the powers to their decimal equivalents. In the third row, start with the highest number and determine how many times it fits into the number being converted; 512 fits into 837 one time, so a 1 is entered in row 3. Subtract 512 from 837, which leaves 325. Move to the next column, and determine how many times 256 fits into 325; it is one, so place a 1 in row 3. Subtract 256 from 325; 69 remains. The next column is 128, which won’t fit into 69, so a 0 is entered in row 3. Keep following this procedure until all of the spaces in row 3 are filled in--if a number fits, enter a 1; if not, enter a 0.
Finally, create a fourth row listing the products of rows 2 and 3. Add these products, and the final result is 83710--the same as with the previous method.
2x | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 2-1 |
---|---|---|---|---|---|---|---|---|---|---|---|
Decimal | 512 | 256 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | .5 |
How many? | 1 | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | - |
= | 512 | 256 | 0 | 64 | 0 | 0 | 0 | 4 | 0 | 1 | - |
512 + 256 + 64 + 4 + 1 = 83710
This method is similar to the first one described for converting decimal to binary, except division by 8 is used. Keep dividing until the quotient becomes 0; the remainders make up the octal number.
Decimal | ÷ 8 | Quotient | Remainder |
---|---|---|---|
837 | ÷ 8 = | 104 | 5 |
104 | ÷ 8 = | 13 | 0 |
13 | ÷ 8 = | 1 | 5 |
1 | ÷ 8 = | 0 | 1 |
Starting from the bottom, list the digits from the remainder column: the result is 15058, which equals 83710.
As demonstrated previously, a table can be created. Start at 80, and list as many powers of 8 as necessary to cover the number being converted; in this case, that is 83, or 51210. If dealing with fractions, list negative powers of 8 to the right of 80.
In the second row, convert the powers to their decimal equivalents. In the third row, start with the highest number and determine how many times it fits into the number being converted; 512 fits into 837 one time, so a 1 is entered in row 3. Subtract 512 from 837, which leaves 325. Move to the next column, and determine how many times 64 fits into 325, which is five, so place a 5 in row 3. 5 times 64 is 320, so subtract 320 from 325; 5 remains. The next column is 8, which won’t fit into 5, so a 0 is entered in row 3. The next column is 1s, which fits into 5 five times; enter a 5 in row 3.
Finally, create a fourth row listing the products of rows 2 and 3. Add these products, and the final result is 83710--the same as with the previous method.
8x | 83 | 82 | 81 | 80 | 8-1 |
---|---|---|---|---|---|
Decimal | 512 | 64 | 8 | 1 | .125 |
How many? | 1 | 5 | 0 | 5 | - |
= | 512 | 320 | 0 | 5 | - |
512 + 320 + 5 = 83710
Dividing by 16 is used here. Keep dividing until the quotient becomes 0; the remainders make up the hexadecimal number.
Decimal | ÷ 16 | Quotient | Remainder |
---|---|---|---|
837 | ÷ 16 = | 52 | 5 |
52 | ÷ 16 = | 3 | 4 |
3 | ÷ 16 = | 0 | 3 |
Starting from the bottom, list the digits from the remainder column: the result is 34516, which equals 83710.
Note: If the remainder is greater than 910, use the appropriate hexadecimal digit:
Decimal | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Hexadecimal | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F |
Alternatively, a table can be used for conversion. Start at 160, and list as many powers of 16 as necessary to cover the number being converted; in this case, that is 162, or 25610. If dealing with fractions, list negative powers of 16 to the right of 160.
In the second row, convert the powers to their decimal equivalents. In the third row, start with the highest number and determine how many times it fits into the number being converted; 256 fits into 837 three times, so a 3 is entered in row 3. 3 x 256 = 768, so subtract 768 from 837, which leaves 69. Move to the next column, and determine how many times 16 fits into 69, which is four, so place a 4 in row 3; since 4 x 16 = 64, this leaves 5. The next column is 1s, which fits into 5 five times, so enter a 5 in row 3.
Finally, create a fourth row listing the products of rows 2 and 3. Add these products, and the final result is 83710--the same as with the previous method.
16x | 162 | 161 | 160 | 16-1 |
---|---|---|---|---|
Decimal | 256 | 16 | 1 | .0625 |
How many? | 3 | 4 | 5 | - |
= | 768 | 64 | 5 | - |
768 + 64 + 5 = 83710
Partition the binary digits into groups of three (octets), starting with the least significant digit. Pad the most significant digit with zeros to complete an octet, as necessary:
111001012 = 10 | 100 | 101 = 010 | 100 | 101
Each octet can have a maximum value of 1112, which equates to 78. In the example above, 0102 = 28, 1002 = 48, and 1012 = 58, so 111001012 = 2458.
Binary | 000 | 001 | 010 | 011 | 100 | 101 | 110 | 111 |
---|---|---|---|---|---|---|---|---|
Octal | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
Partition the binary digits into groups of four (quartet), starting with the least significant digit. Pad the most significant digit with zeros to complete a quartet, as necessary:
1100100001112 = 1100 | 1000 | 0111
Each quartet can have a maximum value of 11112, which equates to F16. In the example above, 11002 = C16, 10002 = 816, and 01112 = 716, so 1100100001112 = C8716.
Binary | 0000 | 0001 | 0010 | 0011 | 0100 | 0101 | 0110 | 0111 | 1000 | 1001 | 1010 | 1011 | 1100 | 1101 | 1110 | 1111 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Hexadecimal | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F |
To convert from binary to decimal, follow these steps:
Example - convert 111100102 to decimal:
Binary | + Digit | = | × 2 | = |
---|---|---|---|---|
11110010 | + 1 | 1 | × 2 | 2 |
11110010 | + 1 | 3 | × 2 | 6 |
11110010 | + 1 | 7 | × 2 | 14 |
11110010 | + 1 | 15 | × 2 | 30 |
11110010 | + 0 | 30 | × 2 | 60 |
11110010 | + 0 | 60 | × 2 | 120 |
11110010 | + 1 | 121 | × 2 | 242 |
11110010 | + 0 | 242 | - | - |
The conversion can also be performed by writing each binary digit as its value multiplied by the appropriate power of 2, then adding the products:
111100102 | = (1 × 27) + (1 × 26) + (1 × 25) + (1 × 24) + (0 × 23) + (0 × 22) + (1 × 21) + (0 × 20) |
= 128 + 64 + 32 + 16 + 0 + 0 + 2 + 0 | |
= 24210 |
Converting from octal to binary is the opposite of converting from binary to octal--just look up each octal digit to obtain the equivalent octet:
Octal | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
---|---|---|---|---|---|---|---|---|
Binary | 000 | 001 | 010 | 011 | 100 | 101 | 110 | 111 |
2638 = 010 | 110 | 011 = 101100112
When converting from octal to hexadecimal, it may be easier to first convert to binary, then to hexadecimal. For example, to convert 2638 to hexadecimal:
2638 = 010 | 110 | 011 = 101100112
Group into quartets: 1011 | 0011 (drop or pad with zeros, as necessary), then convert quartets to hexadecimal digits.
Binary | 0000 | 0001 | 0010 | 0011 | 0100 | 0101 | 0110 | 0111 | 1000 | 1001 | 1010 | 1011 | 1100 | 1101 | 1110 | 1111 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Hexadecimal | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F |
1011 | 0011 = B | 3
2638 = 101100112 = B316
To convert from octal to decimal, follow these steps:
Example - convert 2638 to decimal:
Octal | + Digit | = | × 8 | = |
---|---|---|---|---|
263 | + 2 | 2 | × 8 | 16 |
263 | + 6 | 22 | × 8 | 176 |
263 | + 3 | 179 | - | - |
The conversion can also be performed by writing each octal digit as its value multiplied by the appropriate power of 8, then adding the products:
2638 | = (2 × 82) + (6 × 81) + (3 × 80) |
= (2 × 64) + (6 × 8) + (3 × 1) | |
= 128 + 48 + 3 | |
= 17910 |
Converting from hexadecimal to binary is the opposite of converting binary to hexadecimal--just look up each hexadecimal digit to obtain the equivalent quartet; in this case, C51F16:
Hexadecimal | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Binary | 0000 | 0001 | 0010 | 0011 | 0100 | 0101 | 0110 | 0111 | 1000 | 1001 | 1010 | 1011 | 1100 | 1101 | 1110 | 1111 |
C = 1100; 5 = 0101; 1 = 0001; F = 1111
C51F16 = 11000101000111112
When converting from hexadecimal to octal, it may be easier to first convert to binary, then to octal. For example, to convert C51F16 into octal:
C51F16 = 11000101000111112
Group into octets (drop or pad with zeros, as necessary), then convert:
1100010100011111 = 001 | 100 | 010 | 100 | 011 | 111
Binary | 000 | 001 | 010 | 011 | 100 | 101 | 110 | 111 |
---|---|---|---|---|---|---|---|---|
Octal | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
001 | 100 | 010 | 100 | 011 | 1112 = 1 | 4 | 2 | 4 | 3 | 78
C51F16 = 11000101000111112 = 1424378
Hexadecimal can be converted to decimal by substituting hexadecimal letter values with decimal values.
Hexadecimal | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Decimal | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
To convert C51F16 to decimal:
C51F16 = (C × 163) + (5 × 162) + (1 × 161) + (F × 160)C51F16 = (12 × 163) + (5 × 162) + (1 × 161) + (15 × 160)C51F16 = (12 × 4,096) + (5 × 256) + (1 × 16) + (15 × 1)C51F16 = 49,152 + 1,280 + 16 + 15C51F16 = 50,46310
This table lists binary, octal, and hexadecimal values up to 1510.
Binary | 0000 | 0001 | 0010 | 0011 | 0100 | 0101 | 0110 | 0111 | 1000 | 1001 | 1010 | 1011 | 1100 | 1101 | 1110 | 1111 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Octal | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | Decimal | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
Hexadecimal | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F |