## All Your Number Base Are Belong to Me

So in this post I talked a little bit about number bases and how they’re used in floating-point expansions. I thought I’d go a little bit more into them, since I didn’t really explain how they work.

So the number base we’re all familiar with is decimal, obviously. But not many people realize how arbitrary a choice that seems. Consider the number 10, base 10. By what reasoning do we assume that a one followed by a zero represents ten units? If you remember back to grade school, the 1 is in the “tens” place and the 0 is in the “ones” place. So what we’re actually saying when we write the notation “10” (base 10) is that we have one group of ten units, and zero groups of ones, which comes out to ten units. Or, put in another way, number base notation is a convenient way to express complicated integral additions and multiplications. Remember, $\mathbf{10}_{(b10)} = (10^1\times{1})+(10^0\times{0})$.

To really appreciate the arbitrary nature of our number system, you must distinguish between what we call or name things, and what the thing actually is. Notice that when I write “20”, you immediately associate that notation with a specific number, namely the sum of the number 1 a certain number of times.

But what is “20 base 10”, which I’ll call $\mathbf{20}_{(b10)}$, in binary? It happens to be $\mathbf{10100}_{(b2)}$. How do I know?

Well take a number in decimal, say $\mathbf{11111}_{(b10)}$. From our grade school understanding, we know this means we have one group of ones, one group of tens, one group of hundreds, one group of thousands, and one group of ten-thousands. Or, put in another way, one group of $10^0=1$, one group of $10^1=10$, one group of $10^2=100$, one group of $10^3=1000$, and one group of $10^4=10000$. When we go from $\mathbf{9}_{(b10)}$ to $\mathbf{10}_{(b10)}$, you can see that we overflow into the tens spot, i.e. when we go from $(10^0\times{9})$ to $(10^1\times{1}+10^0\times{0})$.

So by base 2, we mean the following. The ones place in binary is analogous to the ones place in decimal, with one distinction. Since $2^0=1$, it’s still a ones place, but because it’s in base 2, when we get to $2^1=2$, we overflow into the next place (or the “twos place”). So $\mathbf{2}_{(b10)}$ is represented as $\mathbf{10}_{(b2)}$. When we get to $2^2=4$ we overflow into the “fours place”. When we get to $2^n$, for some natural number n, we overflow into the “n’s place”.

So if we wanted to write $\mathbf{20}_{(b10)}$ in binary, we find the closest place to 20 in binary, which is $2^4=16$, and put a 1 there. $\mathbf{20}_{(b10)}$ is $\mathbf{4}_{(b10)}$ more than $\mathbf{16}_{(b10)}$, so we look for the closest place to 4, which is $2^2=4$, and put a 1 there. Thus we get (and pardon the poor spacing; just line up the |’s):

Places: 16 | 8 | 4 | 2 | 1
Number: 1 | 0 | 1 | 0 | 0

And the number we get is 10100 (base 2), which equals 20 (base 10).

Let’s do another example. Let’s write $\mathbf{68}_{(b10)}$ in base 3.

Places: 81 | 27 | 9 | 3 | 1
Number: 0 | 2 | 1 | 1 | 2

In other words, (27×2)+(9×1)+(3×1)+(1×2) = 54+9+3+2 = 68. So 2112 (base 3) = 68 (base 10).

Number bases get really interesting when you start making them very large or negative. For instance, let’s look at the $\mathbf{463}_{(b10)}$ in base 200:

Places: 16e8 | 8e6 | 40000 | 200 | 1
Number: 0 | 0 | 0 | 2 | 63

(Here, 16e8 means 16 x 10^8 and 8e6 means 8 x 10^6.) Base 200 is very interesting because of its ones place. What does the notation “63” mean in this context? It’s obviously base 10. But that makes no sense, as we’re in base 200. This means we need to define new numbers. In fact, we need to define 200-9 new numbers. Why? Because once we get to 10, we’ll mess up our notation otherwise. Consider if we just wrote this number (in base 200) as 263. 263 (base 200) is actually (2*40000)+(6*200)+(3*1) = 81203 (base 10).

How do we define new numbers? Pretty easily. Let the symbol “&” denote 63 (base 10). Thus, 2& (base 200) = 463 (base 10). A real-life analogy to this can be found by looking at the hexadecimal system, which is used in computing. The hexadecimal digits are 1 through 9, and a, b, c, d, e, and f (representing 10, 11, 12, 13, 14, and 15 in base 10 respectively).

Let’s look at base 1, just for kicks. Obviously all the place values are 1s. Which is weird. Remember, in base 10, any of the places can only go up to 9. Once we go higher than 9, we overflow to the next place. In general, for base n (where n is integral, not including zero), each place can only go up to |n|-1 before overflowing into the next place. So for base 1, each place can only go up to 1-1=0. Which means our notation fails at capturing a base 1 system. We may define a special system in this case, which is sometimes done. Define a number in base 1 as successive 1’s representing the number of units it has. So for example, $\mathbf{11111}_{(b1)}$=$\mathbf{5}_{(bk)}$, for $k \geq 6$. In other words, we’re just counting one at a time. So we could replace the 1’s with anything, as long as they’re the same. They’re just hatch marks, so to speak.

Let’s look at an example of a negative number base, say base -2. The place values of base -2 look like this:

Places: (-2)^4 | (-2)^3 | (-2)^2 | (-2)^1 | (-2)^0

or

Places: 16 | -8 | 4 | -2 | 1

This is very interesting. What this means is with a negative number base we can represent both negative and positive numbers using only positive numbers. For instance, $\mathbf{1101}_{(b-2)}$ = $\mathbf{-3}_{(b10)}$, but $\mathbf{110}_{(b-2)}$ = $\mathbf{2}_{(b10)}$. Isn’t that weird? $\mathbf{1101}_{(b-2)} < \mathbf{110}_{(b-2)}$. From our ethnocentric decimal intuition, this looks mighty strange. If there existed a culture that used base -2, they would find it just as intuitive as we find base 10. And they would probably scoff at the fact that we have to have a separate symbol for negative numbers in base 10!

### 4 responses to this post.

1. this post reminds me of counting in binary using your 10 fingers
biggest number using 10 fingers in base 10: 10
biggest number using 10 fingers in binary: 1023

and imagine hands + base2 + ieee 754 !

2. Posted by mindloop on August 1, 2007 at 1:22 pm

Did you know that all integers can be expressed with a finite number of digits in base golden ratio?

3. Posted by mindloop on August 1, 2007 at 1:26 pm

Here are the first 30 in base phi without repeating 1’s:

1 1
2 10.01
3 100.01
4 101.01
5 1000.1001
6 1010.0001
7 10000.0001
8 10001.0001
9 10010.0101
10 10100.0101
11 10101.0101
12 100000.101001
13 100010.001001
14 100100.001001
15 100101.001001
16 101000.100001
17 101010.000001
18 1000000.000001
19 1000001.000001
20 1000010.010001
21 1000100.010001
22 1000101.010001
23 1001000.100101
24 1001010.000101
25 1010000.000101
26 1010001.000101
27 1010010.010101
28 1010100.010101
29 1010101.010101
30 10000000.10101001

Or, if you don’t like repeating 0’s:

1 1
2 1.11
3 11.01
4 11.1111
5 101.1111
6 111.0111
7 1010.1101
8 1011.1101
9 1101.1101
10 1111.0101
11 1111.111111
12 10101.111111
13 10111.011111
14 11010.110111
15 11011.110111
16 11101.110111
17 11111.010111
18 101010.10101111
19 101011.10101111
20 101101.10101111
21 101110.11101111
22 101111.11101111
23 110101.11101111
24 110111.01101111
25 111010.10111111
26 111011.10111111
27 111101.10111111
28 111110.11111111
29 111111.11111111
30 1010101.11111111