|
|
Decimal, Binary and Hexadecimal
Let's learn to count...
But before you go on you can look at this
BINARY, HEX, DECIMAL CONVERTER TOOL!
Decimal number system:
Before we start with the new stuff we will take a look at the number system which we all know the decimal number system. Starting with something we already know will make it easier to introduce the concepts we will use in the other numbering systems. We have ten digits, 0 to 9. This is what we call a base 10 number system (radix of 10). It is really arbitrary that we wound up using a base 10 number system, but it probably has something to do with the fact that we have 10 fingers.
Start counting: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, and you will find that there are no more digits left. How do we continue counting when we only have 10 digits? We add a second column of digits, worth ten times the value of the first column. Start counting again: 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 (Note that the right column goes back to zero here!), 21, 22, 23, ... , 94, 95, 96, 97, 98, 99, and once again, there are no more digits left. The only way to continue counting is to add yet another column worth ten times as much as the one before. Continue counting: 100, 101, 102, ... 997, 998, 999, 1000, 1001, 1002, etc.
Another way to look at the numbers is to write decimal numbers in expanded notation.
365 = 3×100 + 6×10 + 5×1.
1032 = 1×1000 + 0×100 + 3×10 + 2×1.
By writing numbers in this form, the value of each column becomes “clearer”.
Binary number system:
Now let us take a look at the binary base 2 number system (radix of 2). The binary number system works in the exact same way as the decimal system, except that it contains only two digits, 0 and 1. Start counting in binary: 0, 1, and you will need a system to keep on counting. In order to keep counting, we need to add a second column worth twice the value of the column before. We continue counting again: 10, 11, and it is time to add another column again. Counting further: 100, 101, 110, 111, 1000, 1001, 1010, 1011, 1100, 1101, 1110, 1111.... Watch the pattern of 1's and 0's. You will see that binary works the same way decimal does, but with fewer digits.
| Binary: | Decimal: |
| 0000 | 0 |
| 0001 | 1 |
| 0010 | 2 |
| 0011 | 3 |
| 0100 | 4 |
| 0101 | 5 |
| 0110 | 6 |
| 0111 | 7 |
| 1000 | 8 |
| 1001 | 9 |
| 1010 | 10 |
| 1011 | 11 |
| 1100 | 12 |
| 1101 | 13 |
| 1110 | 14 |
| 1111 | 15 |
|
|
| Binary: | Decimal: |
| 0001 0000 | 16 |
| ... | ... |
| 0001 1111 | 31 |
| 0100 0000 | 32 |
| ... | ... |
| 0011 1111 | 63 |
| 0100 0000 | 64 |
| ... | ... |
| 0111 1111 | 127 |
| 1000 0000 | 128 |
| ... | ... |
| 1111 1111 | 255 |
|
Convert from Binary to Decimal:
Converting a binary number into decimal is easy once you get the hang of it.
Step1: Write down the binary number you want to convert, in this case 1111 1111.
| Binary 8 Digit Number: | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
Step.2: Count your binary digits right to left starting at zero. Since we have 8 binary digits this means 0 to 7.
Step.3: Use the number 2 (binary) as base, and the column number (counted above) as exponent 2^n.
Using the power of 2 we will double the value for each column.
| Calculate Decimal Column Value: | 2^7 | 2^6 | 2^5 | 2^4 | 2^3 | 2^2 | 2^1 | 2^0 |
Step.4: It's time to calculate the values from above. You might recognize these values 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, etc..
| Sum Decimal Column Value: | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
Step.5: Add the numbers and the sum will be the valid decimal number 255.
| Decimal Sum: | 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255 | |
Thats it!
Concider the decimal number 255 = 1111 1111 in the table below:
| Binary 8 Digit Number: | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
| Column Number: | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| Calculate Decimal Column Value: | 2^7 | 2^6 | 2^5 | 2^4 | 2^3 | 2^2 | 2^1 | 2^0 |
| Sum Decimal Column Value: | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| Decimal Sum: | 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255 | |
| Alternative Sum: | 2^7 + 2^6 + 2^5 + 2^4 + 2^3 + 2^2 + 2^1 + 2^0 = 255 | |
Concider the decimal number 169 = 1010 1001 in the table below:
| Binary 8 Digit Number: | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 1 |
| Column Number: | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| Calculate Decimal Column Value: | 2^7 | - | 2^5 | - | 2^3 | - | - | 2^0 |
| Sum Decimal Column Value: | 128 | 0 | 32 | 0 | 8 | 0 | 0 | 1 |
| Decimal Sum: | 128 + 0 + 32 + 0 + 8 + 0 + 0 + 1 = 169 | |
| Alternative Sum: | 2^7 + 2^5 + 2^3 + 2^0 = 169 | |
Hexadecimal number system:
Because the binary number system is simple it can be used in advanced digital electronics. It is inefficient for humans to use binary, however, because it requires so many digits to represent a number. The number 76, for example, takes only two digits to write in decimal, yet takes seven digits to write in binary (1001100). To overcome this limitation, the hexadecimal number system was developed. Hexadecimal is more compact than binary but is still based on the digital nature of computers.
Hexadecimal works in the same way as binary and decimal, but it uses sixteen digits instead of 2 or 10. Since the western alphabet contains only ten digits, hexadecimal uses the letters A-F to represent the digits ten through fifteen. We have 16 digits, 0 to F. This is what we call a base 16 number system (radix of 16). We count like this: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.
| Binary: | Decimal: | HEX: |
| 0000 | 0 | 0 |
| 0001 | 1 | 1 |
| 0010 | 2 | 2 |
| 0011 | 3 | 3 |
| 0100 | 4 | 4 |
| 0101 | 5 | 5 |
| 0110 | 6 | 6 |
| 0111 | 7 | 7 |
| 1000 | 8 | 8 |
| 1001 | 9 | 9 |
| 1010 | 10 | A |
| 1011 | 11 | B |
| 1100 | 12 | C |
| 1101 | 13 | D |
| 1110 | 14 | E |
| 1111 | 15 | F |
|
|
| Binary: | Decimal: | HEX: |
| 0001 0000 | 16 | 10 |
| ... | ... | ... |
| 0001 1111 | 31 | 1F |
| 0100 0000 | 32 | 20 |
| ... | ... | ... |
| 0011 1111 | 63 | 3F |
| 0100 0000 | 64 | 40 |
| ... | ... | ... |
| 0111 1111 | 127 | 7F |
| 1000 0000 | 128 | 80 |
| ... | ... | ... |
| 1111 1111 | 255 | FF |
|
Let's count in hexadecimal. Starting from zero, we count 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F. At this point there are no more digits, so we add another column. Continue counting: 10, 11, 12, 13, 14, 15, 16, 17 18, 19, 1A, 1B, 1C, 1D, 1E, 1F. Once again, we are out of digits in the first column, so we add one to the next column. Continue counting once again: 20, 21, 22, ..., 29, 2A, 2B, 2D, 2E, 2F, 30, 31, 32, ..., 3E, 3F, 40, 41, 42, ... 99, 9A, 9B, 9C, 9D, 9E, 9F, A0, A1, A2, ... F9, FA, FB, FC, FD, FE, FF, 100, 101, 102, .... Watch the pattern of numbers and try to relate this to the way you count in decimal or binary. You will see that it is the same procedure, but with sixteen digits instead of 10 or 2.
Each column in hexadecimal is worth 16 times the column before, while each column in binary is worth 2 times the column before. Since 2×2×2×2=16, this means that each hexadecimal digit is worth exactly 4 binary digits. This fact makes it easy to convert between binary and hexadecimal.
Convert from HEX to Binary:
To convert from hexadecimal to binary, simply look at the chart above and replace each digit in the hexadecimal number with its corresponding four-digit binary number. For example, 8F in hexadecimal is 10001111 in binary, since 8=1000 and F=1111.
Convert from Binary to HEX:
To converty from binary to hexadecimal, reverse the procedure above and break the binary number into blocks of four digits. Then, replace each block of four digits with its corresponding hexadecimal digit. If you cannot divide the binary number evenly into blocks of four digits, add zeros to the left side of the number to make it work. For example, to convert 110101 to hexadecimal, first add two zeros at the beginning of the number to make it 00110101. Since 00110101 has eight digits, it can be divided into two blocks of four digits, 0011 and 0101. Since 0011=3 and 0101=5, the corresponding hexadecimal number is 35.
CLICK HERE TO GO TO BINARY, HEX, DECIMAL CONVERTER TOOL!
|
|
|