Go Back   Computer Forums > Articles | Tutorials | Tech Notes > Articles | Computer and Server Software
Click Here to Login
Join Computer forums Today

Thread Tools Search this Thread Display Modes
Old 07-11-2004, 11:13 AM   #1
In Runtime
Join Date: May 2004
Posts: 227
Send a message via AIM to Itsme Send a message via MSN to Itsme
Default Binary Tutorial

Binary in a pretty low number of minutes
By: Itsme

< intro_to_the_tutorial>
I wanted to learn binary a while ago, and I found a lot of tutorials, but many of them werenít complete, or had bugs in them. Thatís why I decided to write this tutorial. (After I found the correct way of course ). Also, I know that there are many tutorials out on the web that are correct, but I still felt like writing my own. For those of you that donít know what binary is, here is part of the definition from www.dictionary.com:

From www.dictionary.com
1. Characterized by or consisting of two parts or components; twofold.
2. Of or relating to a system of numeration having 2 as its base.
Yes, there were 3, 4, and 5 as well, but they had nothing to do with the ďmachine codeĒ binary, so I took them out. So, what is binary? Binary is a base 2 numbering system (Unlike normal numbering for most countries (which is base 10)). It is shown in sets of oneís and zeroís, and each set is 8 characters long. I hope that I havenít lost you too much already .

Well, there really isnít too much to do beforehand. I guess that you could either open up a text editor or get a piece of paper and a big fat pencilÖbut thatís up to you. Also, you should know what the ASCII table is, and how to read it. By read, I do not mean memorize (Unless you are very bored), nor do I mean know why it works. I'll tell you that it is set up like that because whoever made computers figured that that was the easiest way to convert a letter/number/symbol to its decimal equivalent.

. . . . .

Step one: Write the word(s) to be converted
In this step, you will need to write/type the sentences that will later be converted to binary. Truthfully, they donít have to be sentences; there can also be numbers etc. in the sentences. This step is pretty much pointless for me to write, because of how obvious it is . I put it here just in case someone doesn't know. The one thing that you may want to remember when writing/typing the words is that you may want to leave some room under and to the sides of each letter. You are going to be doing some mathematical work, and you will need room to do it.

Step two: Look it up on the ASCII table
Now this shouldnít really be very tricky. All that you need to do in this step is go to www.asciitable.com. Now, as stated above in the intro section, you should know how to read this, BUT, for those of you who donít like to read the intro section, Iíll tell you anyway. On the ASCII table, there are five columns per character. For binary, the only ones that you need to know/worry about are the ones labeled 'Dec' and 'Chr'. If you couldnít guess what those are, they are 'decimal' and 'character'. Now here comes the (not so) hard part: Look up every character that you wrote down and find its decimal number. Yeah, that's it. So, if I had a word that I wanted to convert, say it was 'And', then I would look up a capital 'A', and a lowercase 'n' and 'd'. Then you should write those numbers down. (By the way, yes, it does matter if it is capital or lowercase, because they are different decimal values) I usually do it like this:
A      n       d
65     110     100

Step three: Start the actual conversion
Now comes the fun part. The easiest way to think of this conversion is in binary, a 1 is on, and a 0 is off. So if I use the words on or off, you know which is which . OKÖ

In binary, as was said above, it is base two. So you are using only two numbers; one and two. You will also want to know the following numbers:
128, 64, 32, 16, 8, 4, 2, and 1
And you should memorize them in that order. All that is (if turned backwards) is the number doubled every time (1+1 = 2, 2+2 = 4 and so on) Now the reason that we looked up the decimal value of the letters on the ASCII table might be coming into view. We need to, by only using the numbers given above added together, get the decimal value of the letter. I may be confusing you, and this is better explained with an example. We are going to convert the 'A':

We already found the decimal equivalent of 'A' (65). Using only the numbers above, how can we get 65 (Always using the largest number possible, and NEVER using the same number twice in one character)? Well, 64 and 1 are both up there, and added together they equal 65, so that's it! 64 and 1. Now we come back to the on/off thing. Any number that was used is now considered 'on', and everything else is off. But a computer canít read the word on or off; it can only read a 1 or a 0. Therefore we must go through and see which are on or off (well, we already know, but this is another example):
128    64    32    16    8     4     2     1
off    on    off   off   off   off   off   on
0      1     0     0     0     0     0     1
Now we put it all together and get: 01000001. So in binary, a capital 'A' is 01000001. Now lets get the rest of the word 'And'
n  (letter/number/symbol)
110  (decimal value from ASCII table)
64 + 32 + 8 + 4 + 2 = 110  (added numbers from base2)
128    64    32    16    8     4     2     1
0      1     1     0     1     1     1     0  (on or off)
01101110 (binary equivalent of n)
And for the d:
d  (letter/number/symbol)
100  (decimal value from ASCII table)
64 + 32+ 4 = 100  (added numbers from base2)
128    64    32    16    8     4     2     1
0      1     1     0     0     1     0     0  (on or off)
01100100 (binary equivalent of d)
Now put it all together and you get: And = 010000010110111001100100

That's it!! That's how you do binary!

-All binary characters will ALWAYS be 8 characters in length. Do NOT take off any characters at either end (front or back), even if they are a 0
-When using a number, you still have to look it up on the ASCII table. Just because it is a number doesn't mean you can convert it how it is!

If you find any mistakes, or have any suggestions/comments/etc., please post them here. Thanks a lot!


Itsme is offline   Reply With Quote
Old 07-11-2004, 06:14 PM   #2
Site Team
root's Avatar
Join Date: Mar 2004
Posts: 8,007
Default Re: Binary Tutorial

Ther are a few problems. - bt they are only minor technicalities.
1 binary numbers do not alwas apear in sets of eight.
They apear in groups of 1,2,4,8 and are given different names accordingly.

1 - Bit
2 - Nibble
4 - Word
8 - Byte

Secondly Traditional ASCII charactors actually only have 7 bits as they are signed integers. Extended ASCII codes ake use of the highest bit to introduce a few more charators to the table.

In regular Un-signed binary the numbers are as you said
128 64 32 16 8 4 2 1

1 0 0 0 0 0 0 1 = 129

In signed binary the Most significant bit is a signed digit,

+/- 64 32 16 8 4 2 1
1 0 0 0 0 0 0 1 = -1

For those looking to understand machine code, it is most probably better to get a working knowledge of binary and then move on to hexadecimal, each hex charactr (1,2,3,4,5,6,7,8,9,a,b,c,d,e,f) represents a number 0 - 15.
so each hex digit can represent a binary nibble.
0000 - 0
0101 - 5
1111 - F
good tutorial though.

root is offline   Reply With Quote
Old 07-11-2004, 06:17 PM   #3
Site Team
root's Avatar
Join Date: Mar 2004
Posts: 8,007
Default Re: Binary Tutorial

(Probably heard this before but...)

there are 10 types of people in this world#

those that understand Binary
And those that don't.
root is offline   Reply With Quote
Old 07-11-2004, 06:20 PM   #4
In Runtime
Join Date: May 2004
Posts: 227
Send a message via AIM to Itsme Send a message via MSN to Itsme
Default Re: Binary Tutorial

Yes, what you say is true in your first post. This tutorial was pretty much the basics though...nothing too in-depth. I was really only referring to bytes, in it - nothing else. That is good information (and very accurate), so thank you.

And about your second post - I have a shirt that says that .

Itsme is offline   Reply With Quote

« - | Base 64 tutorial »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

All times are GMT -5. The time now is 08:19 AM.

Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0