[an error occurred while processing this directive] The Computer Inside Out: The Binary System [an error occurred while processing this directive]

The Binary System

One's and Zero's

Most of you have probably heard that computers use one's and zero's. The meaning of this is that computers use the binary system. The binary system is a counting method similar to the human counting system. The difference is that in the binary system, there are only two digits (0, 1), while in the decimal system, there are 10 (0 .. 9). The binary system was chosen in computers over the decimal system because of simplicity, since the computer checks the bit value by using current. With a binary system, only the presence or absence of current needs to be checked in order to obtain 2 different possibilities, while with a decimal system, ten different current intensities would need to be checked in order to obtain 10 different possibilities.

First, some terminology:

Binary numbers can represent any non-negative integer. Scientists, however, also needed a system of representation for negative numbers. Thus, the last bit (left-most) bit usually represents the sign. If the sign bit is a 1, then the number is negative, if it is a 0, then the number is positive. However, life cannot be all that simple, so there is a complication. The table below illustrates this complication:
00000000 Here, as you can see, we start out with the 0, 1, etc. However, when the binary number reaches a point where adding a one would set the sign bit, the number is negated. Thereafter, it simply increases up to -1. Note: an 8-bit signed number can only go between 127 and -128. This is because 2^(number of bits - 1)-1 is the maximum number that can be stored in a binary number with a certain number of bits without setting the sign bit. Thus this allows for 2^(number of bits - 1) different possibilities for each sign (0 .. 127 and -128 .. -1) for a total of the expected 2^(number of bits) possibilities.
10000001
20000010
30000011
40000100
.
.
.
12601111110
12701111111
-12810000000
-12710000001
.
.
.
-311111101
-211111110
-111111111

Now you should have understood the basics of the binary system. We have created a java applet that should clear up some confusion about the binary system. The plus sign is to increase the number by 1, and the minus sign is to decrease by 1. If you want to convert a number to binary, enter it in the text field on the right, and click on the "To Binary" button. Please do not enter values outside the range between -128 and 127 inclusive.


Note: You will need a Java 1.1 compliant browser, such as IE 4.0+, and Netscape 4.5+.

Now that you have an understanding of how this all works, you are ready for the next section. [an error occurred while processing this directive]