|
understanding binary code
Understanding binary code
Very special thanks to Blackswan for this information
Computers are nothing more than a calculator on steroids. The only thing they understand, is numbers. You may see words on the screen when you're chatting on the forums, or realistic graphics while playing your favorite game, but all the computer sees are numbers. Millions of numbers. Thatis the way computers work. They calculate lots of numbers very fast. To understand this, we need to understand how a computer works. A computer is nothing more than a bunch of switches. They only have two positions, on or off. Everything a computer does involves turning these switches on and off in certain sequences.
Let's go back to grade school for a moment. In school we learned about the base ten or Arabic numbering system. which is also called the decimal system. What this means is that we have ten digits in our numbering system. Rember the columns you were taught? Ones, tens, hundreds and thousands, etc remember no column could contain a number higher than 9. When counting, you increase each digit in the right-most place column until you reach 9, then you return to zero and place a 1 in the next column to the left. Well suprise! other numbering systems work the same way. In computer programming we use two numbering systems that are interrelated. The base 2 system, called the binary system, and the base 16 system called the hexidecimal, or hex system.
Computers use the two digit, or binary system to represent how it sets it's switches, either on-0 or off-1 We call such numbers binary numbers (bin means two), and they follow the same basic rules that decimal numbers do: Start with 0, increment to 1, then go back to 0 and increment the next column to the left. For example:
binary-decimal equivelent
0- 0
1- 1
10- 2
11- 3
100- 4
101- 5
110- 6
111- 7
1000- 8
1001- 9
Notice that having only two digits to work with means that your place columns grow rapidly. Because of this there is another numbering system that is used with computers, hexidecimal. Hexidecimai, or hex, as it is called is a base 16 numbering system which means that every places column counts up to sixteen individual digits. Now we have to have somthing to represent the extra six digits. We do this by using the first six letters of the alphabet. Thus the digits for the hexidecimal numbering system are:
0 1 2 3 4 5 6 7 8 9 A B C D E F
Hexidecimal numbers work exactly the same way the other numbering systems do. Count up to the last digit, then return to zero and increment the next column to the left. For example:
hexidecimal-decimal equivelent
0- 0
1- 1
2- 2
3- 3
4- 4
5- 5
6- 6
7- 7
8- 8
9- 9
A- 10
B- 11
C- 12
D- 13
E- 14
F- 15
10- 16
11- 17
and so on.
the hexidecimal numbering system, is the a standard for computer programmers and engineers the world over. It is common when viewing a bin to use a hex editor/viewer that displays the hex values of each character. Hex values are usually shown in groups of four characters consisting of two bytes. One byte=two hex characters, or xx. Two bytes= four hex characters or xxxx.
A byte is, 8 bits in size. It can be represented by a two digit hexidecimal number (00-FF). If you are programming for the Windows platform in C or C++ you have probably noticed the commonly used variable type DWORD (Double-WORD). A WORD is 16 bits iin size, which makes a DWORD 32 bits. If you are an HTML programmer you have probably seen color values that are composed of hex numbers. Colors are represented as a mixture of Red, Green and Blue values (RGB). Each of these three primary colors can have a value from 0-255 (decimal), which translates into three sets of two-digit hexidecimal numbers: 00 1A FF. So you can see we use these hex values tell the computer what to do. Hex values can be designated by a $, $4ff0, or a 0x, 0x4ff0. The $ is the old way, and the 0x is the current method.
|
 Tutorial Tools |
|
|
|
|
|