People fall into 10 groups, those that get binary and everyone else!
The full joke goes: "There are 10 types of people in this world. Those who understand binary and those who don't." If you are puzzed by the statement, read on and become au fait with binary.
We Normally Count in Tens
The most common form of counting and numbers involves the ten digits from 0 to 9. Counting goes thus: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 etc. ad infinitum. When the count gets to 9 there are no more digits to use for the next number, ten, so two digits are used, with the first one representing the number of tens to use and second one the remaining count. Hence 10 is 1 lot of tens + 0, 11 is 1 lot of tens + 1, 12 is 1 lot of tens + 2, etc. Likewise 20 is 2 lots of tens + 0, 21 is 2 lots of ten plus 1 etc. We call this counting in base ten because all numbers are made up of lots of tens, i.e. ten is the base for all the numbers. Base ten is also known as denary or decimal. When we get to 99 and count one more we need to add another number and have a three digit number, so 100 is 1 lot of ten lots of ten + 0 lots of ten + 0 (it is ten lots of ten because we know we have counted to ten, ten times when we have counted to 99 and counted one more). Ten lots of ten has the name a hundred, much easier to say and remember. So 100 is 1 hundred + 0 lots of tens + 0. And their are names to help with bigger numbers, thousand (ten lots of one hundred) and million (one thousand lots of one thousand). Base ten, or decimal, is our normal counting system and we have ten digits on our hands (four fingers and one thumb on each hand), maybe that's were we got it from.
We Can Count in Different Numbers
If only the digits 0 to 7 were available counting would work the same way: 0 1 2 3 4 5 6 7 10 11 12 13 14 15 16 17 20 21 etc. There is no 8 or 9 so we have to move to the next digit earlier when we get to what would have been eight in our normal counting. Thus 10 is no longer representing our normal ten, it is 1 lot of eights + 0, and 11 is 1 lot of eights + 1, 12 is 1 lot of eights + 2, etc. This is counting in eights, base eight, also known as octonary, or octal. So a number like 23 is 2 lots of eight plus 3 (2×8+3=19 in decimal). Maybe if humans had only eight digits on their hands octal would have been our normal counting system.
Counting with the Digits 0 and 1
After starting to count using the digits 0 to 9, for base ten, it was shown that counting works with fewer digits, 0 to 7, base 8. The same principles apply if more digits are removed. What about just two digits, just 0 and 1, base 2. The count is 0 then 1, there is no 2 so we add another digit that represents the number of twos, so 10 is 1 lot of twos + 0 = 2 decimal. 11 is one lot of twos + 1 = 3 decimal. Counting with just the digits 1 and 0 is really quite easy, when adding a 1 to a 1 you carry a one, lengthening the number by another 1 digit if the number is all 1's:
Counting in Base 2 with 1 and 0 | ||
---|---|---|
0 | + 1 | = 1 |
1 | + 1 | Adding 1 to 1, set 0 carry the 1, adding another digit = 10 |
10 | + 1 | = 11 |
11 | + 1 | Adding 1 to 1, all 1's set to 0, carry 1 to end adding another digit = 100 |
100 | + 1 | = 101 |
101 | + 1 | Adding 1 to 1, carry the 1 = 110 |
110 | + 1 | = 111 |
111 | + 1 | Adding 1 to 1, all 1's set to 0, carry 1 to end adding another digit = 1000 |
1000 | + 1 | = 1001 |
1001 | + 1 | Adding 1 to 1, carry 1 = 1010 |
1010 | + 1 | = 1011 |
etc. |
So the count goes 0 1 10 11 100 101 110 111 1000 1001 etc. The method of counting in base 2, using just the digits 0 and 1, is called binary. Looking at the start of the counting sequence in binary it was seen that 0 binary = 0 base ten, 1 binary = 1 base 10, 10 binary = 2 base 10. Now the quip "There are 10 types of people in this world. Those who understand binary and those who don't." would make sense, since 10 is binary for 2.
Bits
Each digit in a binary number is called a bit. Thus the binary number 10011 (19 in decimal) is made up of five bits. A single bit takes the value 0 or 1. Sometimes physical items are used to represent or illustrated a binary value, a concept important when writing computer programs. A light can be off or on. With off representing 0 and on representing 1. Other items can represent such two states such as a gate or door which is closed (0) or open (1), the answer to a question is wrong (0) or right (1), or a statement (the glass is full) is false (0) or true (1).
Each bit in a binary number represents 2x (twice) the value, in decimal, of the number before it with the first number representing 1:
Values of Binary Digits | |||||||||
---|---|---|---|---|---|---|---|---|---|
Bit Position | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 |
Decimal value when set | 256 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
Equals 2x its left neighbour | 2×128 | 2×64 | 2×32 | 2×16 | 2×8 | 2×4 | 2×2 | 2×1 | NA = 1 |
Equivalent To | 2^{8} | 2^{7} | 2^{6} | 2^{5} | 2^{4} | 2^{3} | 2^{2} | 2^{1} | 2^{0} |
Notice the value of a bit is 2 raised to the power of the bits' position minus 1. Thus converting from binary to decimal is done by adding powers of 2.
Converting Binary to Decimal | |||||||||
---|---|---|---|---|---|---|---|---|---|
Bits | 1 | 0 | 1 | 0 | 0 | 1 | 1 | 1 | |
Position | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | |
Value is x2^{pos-1} | 1x2^{7} | 0x2^{6} | 1x2^{5} | 0x2^{4} | 0x2^{3} | 1x2^{2} | 1x2^{1} | 1x2^{0} | |
Equals | 1x128 | 0x64 | 1x32 | 0x16 | 0x8 | 1x4 | 1x2 | 1x1 | |
Total | 128 + | 0 + | 32 + | 0 + | 0 + | 4 + | 2 + | 1 = | 167 |
Converting from decimal to binary is straightforward as well. Since it involves powers of two the number to be converted is divided by two and the remainder written down. This is done until no more division is possible. The written down remainders are the binary bits in reverse:
Converting Decimal to Binary | ||||
---|---|---|---|---|
167 / 2 | = | 83 | remainder | 1 |
83 / 2 | = | 41 | remainder | 1 |
41 / 2 | = | 20 | remainder | 1 |
20 / 2 | = | 10 | remainder | 0 |
10 / 2 | = | 5 | remainder | 0 |
5 / 2 | = | 2 | remainder | 1 |
2 / 2 | = | 1 | remainder | 0 |
1 / 2 | = | 0 | remainder | 1 |
Reading the resulting bits backwards thus 10100111 = 167.
After reading this article I hope you now know which of the 10 groups into which you fall.
Author:Daniel S. Fowler Published: Updated:
↓markdown↓ CMS is fast and simple. Build websites quickly and publish easily. For beginner to expert.
Articles on:
Android, HTML, ↓markdown↓ CMS, VPS, Computing, Computer History
Android Sample Projects:
Android Examples, Android UI Examples