Number is about counting

161 阅读6分钟

Let us count apples in a bag. To make it more fun, we need to forget number, pretending we don't know any concept of number as a newborn baby. Let us get started.

When we get an apple out of bag, we draw a stroke '|' on the blackboard. Repeat this action until there is no apple in that bag. Then those strokes on the blackboard representing how many apple in the bag before we do that counting. Next time, your friend want to exchange oranges for your apples, he think orange is more valuable than apple, so it should use "two" apples for his "one" orange, and he needs "eight" apples. 

How is this deal performed without our knowledge of number? 

Well, do the counting in another way. We get an apple out of bag and put it on the table, and do it again. Then ask your friend to get an orange out of his bag and put it on the table. Afterward we collect the orange on the table and your friend collect the apple. Moreover, your friend puts the apple he collected in another bag, and draw "two" strokes on the blackboard, and we draw "one" stroke on the blackboard. The is one transaction for our deal. Repeat the same procedure of that transaction until there are "eight" strokes on the blackboard. Now the deal is done. your friend got "eigth" apples and we got "four" oranges.

As we would like to reduce the time and effort cost of that deal. Your friend write down strokes of how many apples he wants, then we write down one stroke for each two strokes of your friend's strokes. Then when we get one apple out of bag and put it on the table, we erase one strokes on the blackboard. Repeat this action until there is no stroke on the blackboard. Your friend does the same for oranges. After both finished, we collect the oranges and your friend collects the apples, by put them one by one into a bag while erasing one stroke for one put. Until those strokes are all gone, the deal is done. In this way, we reduce the action of our collections from four to one. It is a good performance gain, right?

And we want to reduce cost further, as we do this kind of deal frequently. Because the strokes are written and erased later on. Can we just draw strokes in our mind? That is to do the counting in our mind. Sure, we remember how many gets and puts to replace drawing and erasing strokes. Then we reduce the stroke drawing of the deal.

But what if there is not "eight" apples to "four" oranges deal, there is "one hundred" apples to "fifty" oranges deal. We cannot remember that many stroke in our brain. The string of strokes in our mind may much longer than our brain. We must make it shorter. That is to use another way for counting as exactly stroke drawing does. Thus we need to see the essential properies of stroke drawing counting.

  1. Each stroke in the stroke sequence means one thing of interest, no matter of its position in the sequence.
  2. The all strokes means the all things of interest.

So we need to conjecture one way to replace stroke and make it more compat so that our little brain can contain eventhough it represents a hug amount of things.

When we count with drawing stroke, we start with an empty sequence of strokes. Then when we count one, e.g. a get from bag or a put into bag, we draw a stroke in that sequece or erase one stroke. Because the position of stroke in the sequence does not matter its meaning. We can force the the addition and remove of troke must be performed at the tail of the end sequence, thus enforce the same distance between adjacent trokes. Therefore the length in vision of the sequence means the same thing as the sequence. That is the length of sequence means how many strokes in that sequence. So when we do good exchange with strok drawing, now we do it with stroke sequence length measuring with ensuring the same distance of adjacent stroke. 

But it is way worse than before. However, it show one thing that "one" stroke sequence has "one" stroke and its length is "one" unit, and "two" stroke sequence has "two" stroke and its length is twice as "one" stroke sequence, and so on for longer sequence of more strokes. Then we abstract a lenght of stroke sequence as a state. Length of "one" stroke sequence as state A, Length of "two" as state B, and so on. Thus we need to use H apples to exchange D oranges from your friend. What if your friend need "twenty-seven" apples? we are out of luck because there are just "twenty-six" letters in our alphatbet for different states. If we recycle those letters for different states, e.g. A for state of "one" stroke sequence, or A for state of "twenty-seven" strokes sequence, we can not distinguish them which one we actually mean. But this time we have the improvement of compatness, that is one letter 'Z' means the same thing for counting as "twenty-six" strokes sequence. Why not invent more letters for repsenting large amount? That should work, but not convenient. It hard remember that many states without pattern for its total order. That is the distance of A to Z should be one longer than B to Z and B to Z is long as A to Y, and the like.

That require us to create an notation with specific pattern to represent different states and their "lengthy" relations. One more thing is that we need one distinguishable "letter" for empty sequence as well. That is meaning of "zero" stroke sequence.

Use our A-Z letter notation for representing states. We need one letter for "zero" stroke sequence, therefore we denote 'A' as "zero" stroke sequence, and 'B' as "one" stroke sequence and so forth. When we meet "twenty-six" strokes sequence, we are out of luck. We may need two letters for it, because one letter from A-Z can represent only "twenty-six" states, and the "twenty-six" strokes sequence is the "twenty-seventh". Then we reuse lettle from A-Z with two letters, as BA for "twenty-six" strokes sequence, BB for "twenty-seven" strokes sequence and so forth. For more than "six hundred and seventy six" strokes sequences, we need three letters, e.g. BAA, or more for larger strokes sequence.

But this time the position does matter. 

For instance of "BCC", the first 'C' from left and the second 'C' does not do same contribution for the whole value of "BCC", i.e. the first 'C' is two "twenty-six" strokes sequnce, and the second 'C' is two strokes sequence. And the 'B' means one "six hundred and seventy six" strokes sequence.

The notation is called Positional Notation of Number system. And the most significant letter is the leftmost one, the least significant letter is the rightmost one for convention. You can revert it to use as well. The most significant letter on the leftmost is call big endian, and the least significant letter on the leftmost is call small endian, by the way.

Now we have our letter number system, e.g. "BCC", which would represent the value of "730" in our modern number system. How this count? Oh, we should recall all our number concept for now to ananlyse our letter number system. 

Back to our question, how come 'BCC' means "730" in decimal. 

Because in our letter number system, there are 26 letters total in our alphabet, therefore, when we represent the 27th state, we need two letters, represent the 676th state, we need three letters, and the same letter in its position would contribute different value to the whole. To make it regular and following the same patten in each position, we state that each position, the ordering of A to Z is the same, i.e. B is one unit next to A, and C is one unit next B, and so forth, when hit the unit next to Z, we start over for that position, that is A, and add one more letter to its left start from B, because there is implicit infinite A letters at the left of explicit letter sequence to the right. That is the value of "AAA...AAABCC" is the same as "BCC" if we fix the length of letter sequence to the longer one.

So for a letter number, e.g. "BCC", there are indexes 0, 1, 2 ... for position started from leftmost letter. Each position has weight, denoted as 'W0' for position 0, 'W1' for position 1 and so forth. The adjacent positions increase weight of a factor of 26 to its left hand side one. That 26 is called radix. Because in one position alone, we only can represent 26 states. Therefore 'W0' is 0, 'W1' is 26, 'W2' is 26 * 26, 'W3' is 26 * 26 * 26 and so forth. That is for index n, the weight of index n is the multiplication of n number of 26, i.e. Wn = 26 * 26 * ... * 26, there are n '26'. Now, we can compute "BCC" as 676 * 26 * 26 + 2 * 26 + 2 = 730.

Now we know how to create a new number system for counting that preserving the whole properties of our stroke drawing counting system.

By use different alphabet, the radix would be size of alphabet, we can have decimal numbering system, whose radix is 10, binary numbering system, whose radix is 2, and so on.

In addition to counting properies which each number system has, different number system will have different advantage in different use cases. For example, binary numbering system is good for computer system, due to the size of its alphabet is 2, it is easy to implement with circuit.