Tuesday, May 3, 2011

DATA REPRESENTATION

We’re used to representing numbers in “base 10.” Presumably this number base makes sense to us because
we have 10 fingers. If our species had evolved with 12 fingers, we would probably have 2 more digits among
the set of symbols we use, and we would find it quite natural to compute sums in base 12. However, we have
only 10 fingers, so let’s start with base 10.
Remember what the columns mean when we write a number like 427. The seven means we have 7 units,
the two means we have 2 tens, and the four means we have 4 hundreds. The total quantity is 4 hundreds, plus
31

2 tens, plus 7. The column on the far right is for units (which you can also write as 100), the next column to the
left is for 10s (which you can also write as 101), and the next column is for 100s (which you can write as 102).
We say that we use “base 10” because the columns correspond to powers of 10—100, 101, 102, etc.
Suppose that we had evolved with 12 fingers and were more comfortable working in base 12, instead. What
would the meaning of 427 be? The seven would still mean 7 units (120 is also equal to 1), but now the two would
mean 2 dozen (121 equals 12), and the four would mean 4 gross (122 equals 144). The value of the number 427
in base 12 would be 4 gross, plus 2 dozen, plus 7, or 607 in our more familiar base-10 representation.
Some people say we would be better off using base 12, also known as the duodecimal or dozenal system.
For example, you can readily find a sixth, a third, a quarter, or a half in base 12, whereas you can only find
a half easily in base 10. Twelve is also a good match for our calendar, our clock, and even our compass. Ah well,
the decision to use base 10 in daily life was made long ago!
The point of this discussion is to show that base 10 is simply one number system of many. One can
compute in base 10, or base 12, or base-any-other-number. Our choice of number system can be thought of as
arbitrary—we’ve got 10 fingers, so let’s use base 10. We could compute just as competently in base 7, or base
12, or base 2.
Computers use base 2, because it’s easy to build hardware that computes based on only two states—on and
off, one and zero. Base 2 is also called the “binary number system,” and the columns in a base-2 number work
the same way as in any other base. The rightmost column is for units (20), the next column to the left is for twos
(21), the next is for fours (22 = 4), the next is for eights (23 = 8), the next is for sixteens (24 = 16), etc.
What is the base-10 value of the binary number 10011010? The column quantities from right to left are 128
(27), 64 (26), 32 (25), 16 (24), 8 (23), 4 (22), 2 (21), 1 (20). So, this number represents 128, plus 16, plus 8, plus
2—154 in base 10.
We can calculate in base 2 after learning the “math facts” for binary math. You learned the math facts
for base 10 when you studied your addition, subtraction, and multiplication tables in elementary school.
The base-2 math facts are even simpler:

0 + 0 = 0
0 + 1 = 1
1 + 1 = 10 (remember, this means 2; and also 0 carry 1 to the next column)
Let’s add the binary value of 1100 to 0110:
1100 (12 in base 10)
0110 (6 in base 10)
10010 (18 in base 10)
rightmost digit: 0 + 0 = 0
next rightmost: 0 + 1 = 1
next rightmost: 1 + 1 = 10 (or 0 carry 1)
next rightmost: carried 1 + 1 + 0 = 10 (or 0 carry 1)
last digit: 1 (from the carry)
So, any kind of addition can be carried out using the binary number system, and the result will mean
the same quantity as the result from using base 10. The numbers look different, but the quantities mean the
same value.

No comments:

Post a Comment