In order for us to make sense of how computers read, write, transmit, and store data, we first need to learn what the binary system is, and how it functions as a logical numeric system.
What exactly is Binary? BIN literally means "composed of two parts" or "both". It is called the Base 2 numeric system. A base is a number which we raise to a certain power (multiply) in order to achieve a given numeric value. You are obviously familiar with the base 10 system. It just makes sense to us, we have 10 fingers, 10 toes, and throughout school a majority of math involves solving problems using sets of numbers grouped in 10's. This is the Base 10 system we use everyday. 10x10=100, or we could say 10 raised to 2nd power=100, hence 102. Or we could say 10x10x10=1000, or 10x10=100x10=1000, or 103 hence 10 to the 3rd power. Binary is much the same as our base 10 system we use in our everyday lives, except instead of counting in 10's we are counting in 2's (hence Base2). So, heres a number in Binary: 10100101. What is this number? Better yet what is this number equal to in the Base 10 system.
First off, lets start by realizing that any number raised to the zero power is 1. Always! Here we are going to convert our Binary number to its decimal equivalent, then it will make more sense to us. Take a look again at that number: 10100101, notice there are 8 places in the number from which to count, just as the Decimal number 375 has 3 places, our Binary number has 8. Counting from right to left starting with the first 1 we have 20, (2 to the 0 power) this is the zero's place, and any number to the zero power is always 1, so we know that that this far right most digit is = to 1 since thereis a 1 in 0's place, although, if there was a 0 here instead if a 1 then it would be 0 since 0x20 = 0. Each place to the left of the fist Bit "Binary Digit" represents a multiple of 2, just as every decimal to the left of its previous digit is a multiple of 10. Lets look at the 8 places of equivalents as multiples of 2: starting from the right and moving left we have 1x20 (1) + 0x21 (0) + 1x22 (4) + 0x23 (0) + 0x24 (0) + 1x25 (32) + 0x26; (0) + 1x27 (128). So we have 1 + 0 + 4 + 0 + 0 + 32 + 0 + 128 which = 165 in Decimal, or 165 Base 10.
Our 8 digits are muliplied in sets of 2, starting from right to left the place values are 0, 1, 2, 3, 4, 5, 6, and 7, respectively giving us a total of 8 digits. Looking back at our 1's and 0's you can see a trend. 1x20 or 0, is the same as saying 20x1 which = 1x1 which = 1. If we had, had a 0 in the far left most Bit then our value would have been 0x20 which would have = 0. Notice that regardless if whether there is a 1 or a 0 in each place, the muliplier remains the same. Since its the 0's place in our example then the given value can only be a 1 or a 0, hence 1x20 = 1, and 0x20 = 0. The 2nd place from the far right most digit is the 1's place, next to it the 2's place, 3's place, 4's place, 5's place, 6's place, and 7's place. So what we are saying is in each place (moving left from right) multiply 2 by the place value, the place value is your exponent, or the number to which you are raising (multiplying) 2 by in order to get your value. Ex: the fourth digit from right to left is the 3's place, so we multiply 2x2x2 or 2x2=4x2=8. How is the fourth spot the 3's place? Because the first digit from the right is in the 0's place! In Decimal we don't count 0 1 2 3 4 5 6 7 8 9 10, we count 0 1 2 3 4 5 6 7 8 9 and then mix these digits to equal a number value. Its the same thing in binary. We have 8 place values but we start with 0.
What about this number: 11111111? Its all one's. So every individual 1 gets multiplied by it's place value. From right to left: 1x20=1 + 1x21=2 + 1x22;=4 1x23;=8 + 1x24;=16 + 1x25;=32 + 1x26;=64 + 1x27;=128 which = 255 in the Decimal system, or 255Base10. Is this making sense yet? Think of it this way look at the decimal value 255. From right to left we have five 1's, five 10's, and two 2's, or 5 + 50 + 200 (255). But I read another tutorial where it stated that 28 is actually 256? Why is it different here? This requires a good explanation that will help to clear up some confusion.
First off if we directly multipplied 2x2x2x2x2x2x2x2 this would directly equal 256, but what you need to consider is that 255 + 0 does infact equal out to 256 total possible values. Where does the 0 come into place? Remember the Binary numeric value we worked with was all 1's, but we never factored 0 as being a number as well. what we are saying is 0 thru 255 (0-255), and since the 0 is a digit itself then we have derived 256 possible values from our equation. In IP addressing (which we will talk about soon) "0" is considered a valid numeric value when creating and assigning addresses. You will also see just how important and how often the value 255 is used when working with IP addresses.
But what if I needed to convert from Decimal to Binary? How would I do that?
You will need to know how to convert from Decimal to binary, so we will cover that here as well:
Converting from Decimal to Binary is simple really. Lets take the Decimal value 196 and convert this number to to its Binary equivalent. To do this we need to remember our 8 place values we worked with before, they are (from right to left starting with 0) 0 1 2 4 8 16 32 64 128. 0's place, 1's place, 2's place, 4's place, 8's place, 16's place, 32's place, 64's place, and 128's place (or places 0 thru 7). we know that 28 is 256. So how many times does the value 196 go into 256? It goes once, so we put a 1 in the 128's place which is the 27 place giving us the Binary number 10000000. Now subtract 128 from 196 which = 68 (remember we put a 1 in the 128's place). So we have 68 left over, now how many times does 64 go into 68? It goes once, so we now put a 1 in the 64's place giving us the Binary value 11000000. 68 - 64 = 4. We now have 4 left over, but 4 is too big a value for the 32's, 16's or 8's places, and since we aren't using those places we put zeros in their spots. The 4 does fit in the 4's place, so we put a 1 there giving us the Binary value 11000100, and now that we've used up all of our values, the last remaining digits are all zeros, so the answer is correct 110001002 = 19610. So we converted 196 our Decimal value accurately to its Binary equivalent which was 11000100, we just added the binary place values to get the conversion (4 + 64 + 128 = 196). There you have it, see not hard to understand at all.Continue...