Tuesday, February 24, 2009

Binary Numbers - how computer counts ?


Quick, what is 11?

9 and 2? or 6 and 5??

Which one???

We express numbers with numerals. The 10 numbers from zero to nine have their own numerals. But larger numbers don’t. To represent them, we re-use the ten numerals in special combinations where groupings of 10 are understood. If we want to talk about one-hundred twenty-three we write

123

where the 3 represents 3 ones, but the 2 represents 2 groupings of 10 ones (ten), while the 1 represents 1 grouping of 10 tens (one hundred). So

123

does not mean 6, even though what we write—1 and 2 and 3—suggests a total of 6. The understood implication of groupings gives this notation the meaning we intend. We regard one hundred twenty-three as being a single one-hundred and also two tens and also 3 ones.

The reason we use groupings of ten is that we have ten fingers, and counting originated on peoples’ fingers.

Other number systems differ. A race of people who had only one hand would have used groupings of 5 to represent numbers greater than five. They would choose to regard one hundred twenty-three as four twenty-fives and four fives and three ones, writing it as

443

A race of people with 4 fingers would regard it as being one sixty-four and three sixteens and two fours and three ones, writing it as

1323

The groupings used are always powers of the base number. If the base number is 10, we use groupings of 1, 10, 100, 1000, … which are 10 raised to the 0, 1, 2, 3, … power, respectively. If the base number is 5, we use groupings of 1, 5, 25, 125, … which are 5 raised to the 0, 1, 2, 3, … power, respectively. If the base number is 4, we use groupings of 1, 4, 16, 64, … which are 4 raised to the 0, 1, 2, 3, … power respectively.

Computers use 2 as the base number. (Maybe computers have only 2 fingers.) They use groupings of 1, 2, 4, 8, 16, 32, 64, 128, … to represent numbers. They regard one hundred twenty-three as one 64 and one 32 and one 16 and one 8 and one 2 and one 1. They write it as

1111011

So quick, what’s 123? Which is correct:

123= 100 + 20 + 3

123= 4x25 + 4x5 + 3

123= 64+ 3x16 + 2x4 +3

123= 64 + 32 + 16 + 8 + 2 + 1 ?

All are correct. So you can use any of the number systems correctly to describe the same set of numbers.

Here are the first 16 numbers, starting from 0, as represented using the base-2 or binary system used in computers:

Decimal

Binary

0

0000

1

0001

2

0010

3

0011

4

0100

5

0101

6

0110

7

0111

8

1000

9

1001

10

1010

11

1011

12

1100

13

1101

14

1110

15

1111

You should be able to convert back and forth.

No comments: