Binary?! What's that?

Welcome to the first installment on computers that I have written. Hopefully this will help you understand how the computer "thinks." As you can see above, this article will focus on something known as binary.

Now, if you don't know what binary is, you're probably asking yourself the very same question as the title to this page. Well, don't worry your pretty little head, all will be revealed. In fact, howzabout right now!


Digits and Bits, Bits and Digits, OH MY!!!

Binary is simply a number system. And, as the name implies, it has to do with two(derived from the prefix bi). In order to understand binary, it's probably best to start with a number system that we all know and love(and one that we'd really love to keep, since it's based off of our very own bodies!) And, the name of that system is decimal.

Just as Binary has "bi" to indicate two, Decimal uses "dec" to indicate ten... Now, of course, we have 10 fingers, and decimal seems well thought out to fit our needs... We can easily count on 2 hands up to ten. In fact, our fingers are known as "digits", and surprise, surprise, each number in decimal is considered a digit! Decimal is considered a base-10 number system, which simply means that it has 10 digits. These digits are familiar to us as {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} A digit is represented as a single character for counting numbers.

OK, very good and fine, but what does this mean. Well, in binary, we use a base-2 system. And that simply means that there are two "digits" In fact, we call these digits "binary digits." And further, you can see that if we want to shorten it(using the bold letters I highlighted in the phrase binary digits), we see that we arrive at the term "bits"!!! Also, when discussing decimal, we saw the numbers used to represents the individual digits, so we might as well do the same here... And those numbers are(and it's probably no surprise to you...) zero and one... Yep {0,1}So:


Places we knew when we were younger

OK, so we know how to write 0 and 1 in binary, but what if we want to go higher than that? This is where we will go over simple math that we learned when we were younger. The funny thing is, that we don't even realize what we are doing when we count numbers like this. We learned this, and it became automatic, so it's important to review how we do it...

You will notice that once we hit nine, in decimal, there are no more digits to tack on, so what do we do? We make another place to the left of our current number to put some numbers... And, that place is called the 10's place...

10's  1's
1     0
Hmm... So, we know that ten comes after nine, and it looks like we put a 1 in the tens place. What this means, is that we multiply 10 by 1, and we arrive at the new number... ten, which is the next number in line after 9. Well, what about eleven?
10's  1's
1     1
Well, we simply multiply the 10's first, and then add the rest of the number to the right. Which means that we do the same thing in the 1's place as we did in the 10's place, and that is to multiply the place by the number in it(1's place x the digit 1)... So, this give us... (tens * 1 + ones * 1) or ten plus 1... or ELEVEN!!!

OK, what about once we hit nineteen? Which is 1 ten plus 9 ones... Well, we simply carry over another digit to the tens... We make the nine in nineteen a zero, and carry over a one(which get's added to the one that's already in the tens spot... Which makes 2(1 in tens already there, plus another 1 equals 2), therefore we have 2 in the ten's place, and 0 in one's...

(2 * 10) + ( 0 * 1) = twenty(20).

Was:  
10's  1's
1     9

And is now:
10's  1's
2     0

One last thing to note, is that the next place in line to the left is always 10 times greater than the one to the right... This is because we're in base-10. So, we if we reach ninety-nine, we'll next go to one hundred, which is 10*10... So, we have a new place to the left of the tens which is 100... And then a thousand(1000), etc... We'll see what this means when we get to binary...

Places we've got to learn about

So, we know how places work in decimal, but what about binary? The concept is quite similar, except instead of 9 digits, we've got two, and instead of places based on 10, we've got places based on two... Observe:

1's
1

Now, we have reached our digit limit(just as 9 is the highest single digit you can write in decimal, 1 is the highest single digit you can reach in binary)

OK, what now? Well, we've reached 1, and we need a 2!!! Hmm... In decimal, once we reached a nine, we simply added another spot, which was the next number up... In that case, it's a 10. In this case, since the next number after 1 is two, we'll make a two's spot!!!

2's  1's
1    0

WAITAMINIT!!! You mean to tell me that two written in binary is 10? I thought that 10 was ten! Well, yes, in decimal, it's ten, but we're working in binary, and that changes the details(but the nice thing is, the rules are still the same!!!)

Remember, to go to the next place, we always take the current largest place, and multiply that by the BASE that we're working in. Since binary is "BASE-2" and the current place was 1's, we'll make the newest place be 2's place(now, note that 2's is written in decimal... There is no digit(or bit) '2' in binary...)

So, what if we want to make 3?(which is kind of like making eleven... In fact, it looks just like eleven!!!)

2's  1's
1    1
We do the same thing we did for eleven in binary... We took the highest place(2's), and multiplied it by the digit(bit) in that place... in this case, it's a 1. So, we have (1(digit/bit) * 2(place))=two, then we add the value to the right, which is (1(digit/bit) * 1(place))=one. Therefore: two plus one equals three!!!! OK, now that we've got both places filled up with the highest number that can occupy it, what do we do?(this is like 99 in decimal. You can't put a higher digit than nine in 10's or 1's in decimal, so you need to make a new place) We need to make a new place!!!

Since the largest place we currently have filled is the 2's place, we simply make a 4's place(remember, multiply the current largest place by the base(in this case 2), to get the new largest place(base2 times 2(the largest current place)=4!!! Another way to look at it, is that we've created 3 by filling up both places, so the next place in line would be 4, since we just made number 3...

4's  2's  1's
1    0    0
This means that we multiply the fours spot by 1 and add the numbers to the right(in this case, 0, so the answer to this is that 100=four in binary!)

Well, what about five? OK, 100 equals four... We need to add one. Well, simple!!! 101( (1*4) + (0*2) + (1*1))

Six? 4 + 2!!! so...

4's  2's  1's
1    1    0
So, this seems to be pretty simple... It just takes a little practice. Perhaps I've explained it in a confusing way, but I hope not. If I have, feel free to ask me some questions, just send mail to kingalfor@inxpress.net

Well, that ends section 2! What's next? Well, read on...


When is a kilo not a thousand?

When is a kilo not one thousand? The answer: when it's a thousand twenty four!!!(1024 in decimal) Why? Well, it has to do with the way binary numbers work. You probably noticed that the places in binary aren't nice "round" numbers like 10, 100, or 1000, but instead, numbers like 2, 4, and 8.

What are the places anyways? Well, of course, the places go on to infinity, since there are an infinite amount of numbers, so I won't go on to all the places, but I will give you the first few...

4096  2048  1024  512  256  128  64  32  16  8  4  2  1
Well, that should make it a little easier for you to see the places and where they go... Of course, as mentioned before, just multiply the largest place by two to get the next place in line. So, the next place after 4096 is 8192.

Since there is no thousand in binary(as a nice round place), we simply use 1024 as a kilo, since it's the closest to a thousand.

bits, nybbles, and bytes...

Now, you may have noticed that it can get kind of confusing if we just have a large string of ones and zeroes... 11010110010110010101 Indeed, it's very confusing, for us. To a computer it's not that confusing. It just read them one at a time(very rapidly, of course). But to make it easier for us, we divide the numbers into little chunks called nybbles and bytes.

As noted before, a bit is the smallest unit in binary notation. Then we can go a little further and make a few larger chunks. The next step up from a bit is a nybble. A nybble is represented by four bits(or places)... The largest number we can represent in a nybble is fifteen. I will give a list of all the nybbles in sequential order:

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
An interesting thing to note, is that the total amount of numbers that can be represented in a place is equal to two times the place:

2*place

For example, if I had a nybble, I could represent 16 numbers. The largest place available in a nybble is 8, and we multiply that by two to find 16.

Another interesting thing to note, is that the largest number that can be represented in a place is equal to two times the place minus one:

2*place-1

in the case of a nybble, there are 4 bits possible, which reach up to the 8's place... Well, we simply multiply 8*2 which is of course, 16, and subtract 1, which leaves us with 15! Then, of course, to get 16, we carry the 1 over to the next place(16's place), and start over.... Now fifteen is the largest number represented in a nybble, but there are a total of 16 numbers that can be represented... You can't forget 0 as a number.

Now, what about a byte? Well, a byte is simply represented by 8 bits, which would take us to the 128 place. What would be the total amount of numbers we could represent with a byte? Well, 256! To find that out, simply multiply the place by two to find that amount of numbers... But, since we start at zero, the largest number represented is 255(remember two times the place minus 1) How do we show a byte? Why is a byte easier to read? Because we use spaces to separate nybbles from each other. As I said, the computer reads it all as one string, but it's easier for us to organize it into chunks... here's a few examples of bytes...

0001 0000
0001 0001
0001 0010
0001 0011
0001 0100
0001 0101
0001 0110
0001 0111
0001 1000
0001 1001
0001 1010
0001 1011
0001 1100
0001 1101
0001 1110
0001 1111
0010 0000
And so on... Note that this is in sequential order of 16-32. See how much easier it is to read it with spaces between nybbles? In fact, if you think in terms of the decimal system, the spaces are kind of like commas, but instead of between 3 digits, the spaces go between 4 digits...

....

Well, I've decided to end this for now, as it's getting quite long. However, there will more added to this little tutorial on binary numbers. Mainly two:
  1. Why a computer uses binary instead of decimal
  2. the ASCII code
And also note that eventually, this will be part of a larger reference work for beginners, tentatively titled "The moron's index to computer knowledge" or something like that. And also note that I hope to make this an interactive tutorial, with quizzes to help reinforce what you've learned, and perhaps more.

Again, please write to me and let me know what you think of this tutorial. Whether it was helpful, what you think could be done to explain things better, if you have any questions on the content(ie:"what does THIS mean?"), or pissin and moanin... Whatever. Please, just let me know what you think. And, as I said, I will be organizing it a little better, so please don't complain that it's too long, because that's something I will work on.

©Dave Elliot(kingalfor@inxpress.net) Last Updated: Aug. 2,1998