Online Book Reader

Home Category

Code_ The Hidden Language of Computer Hardware and Software - Charles Petzold [24]

By Root 1586 0

7 x 64TEN +

2 x 8TEN +

5 x 1

This is the same thing with the powers of eight shown in their octal form:

3725EIGHT = 3 x 1000EIGHT +

7 x 100EIGHT +

2 x 10EIGHT +

5 x 1

Here's another way of doing it:

3725EIGHT = 3 x 83 +

7 x 82 +

2 x 81 +

5 x 80

If you work out this calculation in decimal, you'll get 2005TEN. This is how you can convert octal numbers to decimal numbers.

We can add and multiply octal numbers the same way we add and multiply decimal numbers. The only real difference is that we use different tables for adding and multiplying the individual digits. Here's the addition table for octal numbers:

+

0

1

2

3

4

5

6

7

0

0

1

2

3

4

5

6

7

1

1

2

3

4

5

6

7

10

2

2

3

4

5

6

7

10

11

3

3

4

5

6

7

10

11

12

4

4

5

6

7

10

11

12

13

5

5

6

7

10

11

12

13

14

6

6

7

10

11

12

13

14

15

7

7

10

11

12

13

14

15

16

For example, 5EIGHT + 7EIGHT = 14EIGHT. So we can add two longer octal numbers the same way we add decimal numbers:

To begin with the right column, 5 plus 3 equals 10. Put down the 0, carry the 1. One plus 3 plus 4 equals 10. Put down the 0, carry the 1. One plus 1 plus 6 equals 10.

Similarly, 2 times 2 is still 4 in octal. But 3 times 3 isn't 9. How could it be? Instead 3 times 3 is 11EIGHT, which is the same amount as 9TEN. You can see the entire octal multiplication table at the top of the following page.

x

0

1

2

3

4

5

6

7

0

0

0

0

0

0

0

0

0

1

0

1

2

3

4

5

6

7

2

0

2

4

6

10

12

14

16

3

0

3

6

11

14

17

22

25

4

0

4

10

14

20

24

30

34

5

0

5

12

17

24

31

36

43

6

0

6

14

22

30

36

44

52

7

0

7

16

25

34

43

52

61

Here we have 4 x 6 equaling 30EIGHT, but 30EIGHT is the same as 24TEN, which is what 4 x 6 equals in decimal.

Octal is as valid a number system as decimal. But let's go further. Now that we've developed a numbering system for cartoon characters, let's develop something that's appropriate for lobsters. Lobsters don't have fingers exactly, but they do have pincers at the ends of their two front legs. An appropriate number system for lobsters is the quaternary system, or base four:

Counting in quaternary goes like this: 0, 1, 2, 3, 10, 11, 12, 13, 20, 21, 22, 23, 30, 31, 32, 33, 100, 101, 102, 103, 110, and so forth.

I'm not going to spend much time with the quaternary system because we'll be moving on shortly to something much more important. But we can see how each position in a quaternary number corresponds this time to a power of four:

The quaternary number 31232 can be written like this:

31232FOUR = 3 x 256TEN +

1 x 64TEN +

2 x 16TEN +

3 x 4TEN +

2 x 1TEN

which is the same as

31232FOUR = 3 x 10000FOUR +

1 x 1000FOUR +

2 x 100FOUR +

3 x 10FOUR +

2 x 1FOUR

And it's also the same as

31232FOUR = 3 x 44 +

1 x 43 +

2 x 42 +

3 x 41 +

2 x 40

If we do the calculations in decimal, we'll find that 31232FOUR equals 878TEN.

Now we're going to make another leap, and this one is extreme. Suppose we were dolphins and must resort to using our two flippers for counting. This is the number system known as base two, or binary (from the Latin for two by two). It seems likely that we'd have only two digits, and these two digits would be 0 and 1.

Now, 0 and 1 isn't a whole lot to work with, and it takes some practice to get accustomed to binary numbers. The big problem is that you run out of digits very quickly. For example, here's how a dolphin counts using its flippers:

Yes, in binary the next number after 1 is 10. This is startling, but it shouldn't really be a surprise. No matter what number system we use, whenever we run out of single digits, the first two-digit number is always 10. In binary we count like this:

0, 1, 10, 11, 100, 101, 110, 111, 1000, 1001, 1010, 1011, 1100,

1101, 1110, 1111, 10000, 10001…

These numbers might look large, but they're really not. It's more accurate to say that binary numbers get long very quickly rather than large:

The number of heads that humans have is 1TEN or 1TWO

The number

Return Main Page Previous Page Next Page

®Online Book Reader