| RJL BinaryCards™ |
|
Send
encoded greeting cards over the internet |
Back to Basics - Binary
Numbers and Computers
by By Alex Dumestre — http://www.1960pcug.org 1960 PC Users Group,
January 1999., dumestrea@pdq.net - April
24, 1999 at 00:14:17
The Development of Number
Systems—Early civilizations experimented with all sorts of ways to say and
write numerical quantities. Many started with simple tally marks – four
baskets of oats were recorded as four marks on a wet clay tablet, e.g., ////.
Easy enough! 14 baskets of oats already started getting rather cumbersome:
//////////////. 322 baskets went far beyond the pain threshold. Some
civilizations decided to use tally marks for small numbers but to invent
different marks for larger groups of objects. For example one could use a / for
one item but perhaps a ^ for ten items. One very familiar system built on this
concept is known to us as Roman numerals. In this system a unit is represented
by I, five is represented by V, ten by X, 50 by L, 100 by C, 500 by D and 1000
by M. String together as many of these symbols as it takes to represent the
number you have in mind. As an example, the year 1066 is written as MLCVI. This
is not too bad as a way to record numbers but just try doing arithmetic with
Roman numerals! Try dividing MCDIX by XLIII without converting to Arabic
numerals. This is not an article about Roman numerals so we will leave it at
that except for a couple of interesting things: Note that larger groups that
received their own symbols came in multiples of 5 and 10.
There is no way to write the number
zero in Roman Numerals. If the fact that 5 and 10 have some special place in
Roman numerals doesn’t strike you as strange, that is probably because of two
things—People have 5 fingers on each hand and 10 fingers total and fingers
were the first counting aids.
Our own familiar number system—the
decimal system – uses 10 in a special way.
Some civilizations used other numbers
as the base of their number systems. 60 was popular with the Babylonians and
remnants of that still show up in our time and angular systems. 12 was another
base sometimes used and also remains in our clock and dozen and gross, etc. 20
shows up in some systems. But for human convenience, ten has won out, hands
down.
Positional Systems —Mention was
made earlier about the number zero. The whole concept of zero was missing from
most of the primitive number systems, including Roman numerals. Zero did show up
in the Babylonian and in the Mayan systems, though. The reason I mention it is
that zero is fundamental in any positional number system. Our customary number
system is decimal (or base ten) and, more to the point, it is a positional base
ten system. Rather than try to define that abstractly let’s explain by
example. Our base ten system is made up of only 10 distinct digits. These are
not the numbers 1 through 10, but rather the numbers 0 through 9. In this system
one counts 0 1 2 ...7 8 9, thus using up all of the available digits. To go
higher one just reuses the same set of digits but positions them one place to
the left and they thereby take on values ten times their normal value. That
carries us to 99 at which point we simply shift one more place to the left and
continue up to 999. Once established, this scheme has no upper limit. With it we
can write numbers in the millions or write the national debt or the distance to
the edge of the universe in centimeters! This is powerful! According to this
scheme, the digit 3 can have the value 3 or the value 30 or the value 300 or
30000 depending only on where it is positioned in the number. In the general
case, we require the digit 0 to allow us to identify that position. Reverting to
Roman numerals, we can write the value one thousand and three as MIII. Look ma,
no zero. But in our traditional system, if we attempted the same thing, we would
get 13 or 1 3 if we did not have zeros to mark empty positions. We are much more
comfortable with 1003.
Let’s review.—In a positional
number system, we first use up all of the available digits, in order. Then we
carry 1 (move over one place left and put a 1or increment whatever digit is
already there) and run through all of the digits again. Continue this as long as
necessary to count up to the value we need.
Base ten is convenient for us but not
for computers. They don’t have ten fingers; they have transistors and
transistors have only two fingers (really two states – on/off or, by
convention, 0/1). Bummer. Not very exciting. The saving grace for computers is
that although transistors can only count to two there are an awful lot of
transistors. So if we try to count using transistor states we can count 0, 1 on
our first transistor but to count up one more we must carry to the next
transistor. Simplistic as this is we can continue this indefinitely as long as
we can carry to yet other transistor. Since only two digits are available this
is called the binary system and each binary digit is called a bit.
Let’s list the first several
counting numbers in both the traditional base ten system and in the binary
system. The bold numbers in the formula shown below are the positional
multipliers.
To illustrate the use of the
positional multiplier, take the decimal number 13. Its value is (1 x 10) + (3 x
1) = 13. In like manner the binary number 1101 has a value of (1 x 8) + (1 x 4)
+ (1 x 1) = 13. In the decimal system the positional multipliers are 1, 10, 100,
1000, 10000 all powers of ten, i.e. 1 x 10 = 10, x 10 = 100, x 10 = 1000.
Powers of Two—Now look at the
positional multipliers in the binary table above. They progress 1, 2, 4, 8, 16.
Each number is double the previous one. If we continued this process, we would
get .32, 64, 128, 256, 512, 1024, 2048, 4096.etc. These numbers are all powers
of two. That is, 2 squared (2 x 2) is 4, 2 cubed (2 x 2 x 2) is 8, 2 to the 4th
power is 16, etc.
Notice that the series of numbers in
the preceding paragraph contains many of the numbers that you routinely
encounter in dealing with and reading about your computer. Some xamples: 8 bits
to the byte; 16 bit soundboards; 32-bit software for Windows 95/98; 64 Mb of
RAM; etc.
Let’s wrap things up with a little
computer math review. How do we determine that 8 bits will give us 256 values?
Each bit provides two choices and each additional bit doubles the total number
of values. Therefore 8 bits = 28 = 2 x 2 x 2 x 2 x 2 x 2 x 2 x 2 = 256. Where
did the numbers 65,000 (Hi-Color) and 16.7 million (True Color) come from? Both
of these are just approximations to simplify talking about them. Let’s take
the big one first. Remember that 24-bit color depth is actually made up of three
8-bit R, G and B channels. Since each of 256 shades of red can be combined with
each of the 256 shades of green we can end up with 256 x 256 = 2562 = 65536
possible red-green combinations. Since each of these combinations can be
combined with any of the 256 shades of blue we end up with 256 x 65,536 = 2563 =
16,777,216 which we refer to as 16.7 million. A more direct calculation is 224 =
16,777,216. Finally, the hi-color mode on PCs uses a total of 16 bits, rather
than 24 bits, to store all three-color channels. This leads to the calculation
of 216 = 65,536, which is commonly referred to as 65 thousand or 64K. (Although
we have a tendency to think that K stands for 1,000, it actually stands for 210
= 1,024. 64K = 64 x 1,024 = 65,536.) [Editor’s note: K does stand for 1000,
except in special Computer circumstances. A Kilo Hertz is still 1000 cycles per
second.] Working with computers, we can never escape “powers of two.” By the
same token, we tend to think that Meg stands for one million, whereas it
actually stands for 220 = 1048576. [Ed note: See above.] So, 16 Mega bytes of
memory is really not 16 million bytes but rather 16 x 1,048,576 = 16,777,216
bytes. Now, aren’t you glad you asked?
There are other number bases that are
used around computers but these are important mainly to programmers; however,
users may sometimes encounter them. We’ll defer a discussion of hexadecimal
and octal numbers until later.
Alex Dumestre has been associated
with computers for over 30 years, most of that time writing geophysical
applications for use on main frame, minicomputers, and workstations. He is,
however, a novice on PCs. Mr. Dumestre is a member of the 1960 PC Users Group,
and can be contacted via e-mail at dumestrea@pdq.net
Click here to send a BinaryCard Message
|
|