Introduction
Are you hesitant about learning the computer’s own language—the Binary Number System? I hope not! If you are a programmer or plan to become one, then I strongly recommend that you learn it. No, you won’t be writing full programs in binary, but sooner or later, you will encounter Binary, Octal, and Hexadecimal numbers. If you want to avoid surprises, it’s best to build a solid understanding of these number systems early on.
The good news is—it’s not as hard as it may sound. In fact, once you understand a few simple rules that apply to our familiar decimal system, you’ll discover that you can devise and work with any number system, as long as others can also interpret it and agree on its usage.
Simple Rules that Govern the Decimal Number System.
Let us explore a few simple rules that go with the Decimal Number System, which we are already familiar with.
The Decimal Number System.
The decimal Number System's Base value is 10, which is known as the Base-10 Number System.
The Base-10 Number System has 10 digits to express quantities; 0 to 9, and the highest digit value is 9, i.e., one less than the Base value of 10.
Any value more than 9 is expressed in multiples of 10.
Note: Keep this simple rule in mind: when you create a number system with a particular Base, the total number of digits in that system will always be equal to the Base value. The largest single digit in that system will be one less than the Base. You’ll see this rule in action when we explore other number systems commonly used in computers, such as Octal and Hexadecimal.
Decimal value 10 cannot be written with a single digit; instead, we put a zero in the unit's position and write 1 in the 10th position. So, decimal Value 10:
10^1 = 10x1= 10
100 (1 x 0) = 0
10+0 = 10
Let us create a table to see how each digit value is calculated and added up to the decimal quantity.
Note: Please use your Laptop or Tablet to view the Table correctly.
106 | 105 | 104 | 103 | 102 | 101 | 100 |
1,000,000 | 100,000 | 10,000 | 1,000 | 100 | 10 | 1 |
2 | 5 | 5 |
2 x 102 OR 2 x 10 x 10 OR 2 x 100 = 200
5 x 101 OR 5 x 10 = 50
5 x 100 OR 5 x 1 = 5
=======
255
=======
Following the above rules, we can devise any number system. For example, if we create a number system with Base 8, it will use the digits 0 to 7. The highest single-digit value is always one less than the base, so in this case, 7. This system does not include the digits 8 or 9. In fact, this Base-8 system—known as the Octal Number System—has long been used in the computer world. We will study it in detail after exploring the Binary Number System.
Binary Number System.
By keeping the above simple rules in mind, we will learn the Binary or Base-2 Number System. This Number System has only two digits, 0 and 1 (the highest digit value is 1, i.e., one less than the base value 2) to write any Decimal value in Binary form.
First, let us create a Binary Table, similar to the decimal table, like the decimal number table, so that converting Decimal Numbers to Binary and vice versa is easy.
Note: Please use your Laptop or Tablet to view the Table correctly.
215 | 214 | 213 | 212 | 211 | 210 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 |
32,768 | 16,384 | 8,192 | 4,096 | 2,048 | 1,024 | 512 | 256 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
In the above table, each digit position value is given in the second row. For example, if you put 1 below the value 1024 and fill the other slots to the right with all zeroes, then the value of Binary Number 10000000000 is 1024 (or 1K or 210). If you put 1 replacing the rightmost 0 (10000000001), then the Binary Value becomes 1024+1 = 1025.
Let us try converting the small decimal number 10 to binary.
Method-1:
To convert the decimal number 10, we look at the table and find the highest integer value that can be subtracted from it. In this case, the highest value is 8.
- Subtract 8 from 10 and find the result.
10
-8
====
2
====
- Put 1 under the slot of value 8 in the binary table.
- Next, value 2 can be subtracted from the balance value 2 above.
2
-2
=====
0
=====
- Put 1 under the value 2 in the binary table. The remainder is zero (0), so put a 0 in the unit position of the binary table. So the result of Decimal Number 10 in binary form is 1010 as given below:
215 | 214 | 213 | 212 | 211 | 210 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 |
32,768 | 16,384 | 8,192 | 4,096 | 2,048 | 1,024 | 512 | 256 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
1 |
Now, we have 2 as the balance value, and the next binary position value is 4. 4 cannot be subtracted from 2, so put a 0 under the value 4.
215 | 214 | 213 | 212 | 211 | 210 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 |
32,768 | 16,384 | 8,192 | 4,096 | 2,048 | 1,024 | 512 | 256 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
1 | 0 |
215 | 214 | 213 | 212 | 211 | 210 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 |
32,768 | 16,384 | 8,192 | 4,096 | 2,048 | 1,024 | 512 | 256 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
1 | 0 | 1 | 0 |
Cross-Checking the Result.
You can quickly cross-check whether the binary number is correct for the decimal number by adding up the values in the second row wherever 1 is there in the third row; 8+2 is 10.
It is not always convenient to build the above table whenever we want to convert a decimal number to binary. Instead, we can do it with a simple calculation. Let us convert the decimal number 10 to binary with this new method.
Method-2:
Divide the decimal number by 2 and record the remainder (always 0 or 1, since this is integer division). Begin constructing the binary value from right to left, placing each remainder in order.
- Each time takes the Quotient Value from the previous division and divides it by 2 again.
10/2 = Quotient = 5, Remainder=0
215 | 214 | 213 | 212 | 211 | 210 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 |
32,768 | 16,384 | 8,192 | 4,096 | 2,048 | 1,024 | 512 | 256 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
0 |
5/2 = Quotient = 2, Remainder = 1
215 | 214 | 213 | 212 | 211 | 210 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 |
32,768 | 16,384 | 8,192 | 4,096 | 2,048 | 1,024 | 512 | 256 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
1 | 0 |
2/2 = Quotient=1, Remainder = 0
215 | 214 | 213 | 212 | 211 | 210 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 |
32,768 | 16,384 | 8,192 | 4,096 | 2,048 | 1,024 | 512 | 256 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
0 | 1 | 0 |
1/2 = Quotient = 0, Remainder=1
215 | 214 | 213 | 212 | 211 | 210 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 |
32,768 | 16,384 | 8,192 | 4,096 | 2,048 | 1,024 | 512 | 256 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
1 | 0 | 1 | 0 |
If you have understood this simple number system so far, try converting some larger numbers than we have practiced. As seen in the binary table above, the highest value listed is 32,768 (2¹⁵). However, you can attempt to convert any decimal number below 65,536 using the same table.
If you need a sample number, then try converting the decimal number 255 to binary.
[...] ToolbarViral PDF eBooks - turn your PDF documents into a viral sales force Related Links:Learn Binary Numbering SystemConverting From Decimal to Binary, Octal, and HexadecimalDigital Electronics MCQ Free Download PDF [...]
ReplyDeleteHi, and thanks for the comment on my post on understanding binary! I think yours is intended for the more confident reader, whereas mine has the goal of giving a brief introduction to those who feel they are in some way not as mathematical. Yours may well be a good place to take a step up from mine (similarly, mine may be a good place to start for any who find yours starts off too high!)
ReplyDeleteJust in case, mine's here: http://mathsqs.blogspot.com/2010/10/how-does-binary-work.html
Thanks for the review TeaKayB.
ReplyDeleteRegards,
Here is a good site for people wanting to learn binary and hexadecimal.
ReplyDeletehttp://justwebware.com/bitwise/bitwise.html