Usually, a digit refers to a value written in base 10, between 0 and 9. Non-negative numbers written in base 10 are a sequence of one or more digits.

However, I want to use a more general definition, which allows a digit to be a single value written in base K, instead of simply in base 10.

Just so you don't get confused, I will write the base of a number as a subscript. For example, 723DefinitionAdigitis a single symbol used to represent a value in base K.

Suppose a number has N digits. To make it easier to talk
about each digit, I will subscript the digits from right
to left, starting with the subscript 0. Therefore, an N digit
value will look like: **d _{N-1} d_{N-2} ... d_{1}
d_{0}**.

For example, for the number 723, the digits are **d _{2}=7,
d_{1}=2, and d_{0}=3**. I'll explain why the digits
are subscripted

To answer this, let's pick a specific base to work in. What is the valid range of digits in base 10? The valid digits range from '0' through '9' inclusive.

In binary (base 2), the valid values are 0 and 1.

Do you see a pattern? Notice that the range of the values for a single digit always fall short of the base itself. Thus, for a arbitrary base, K, the valid range of values for a single digit are between 0 and K - 1, inclusive.

That raises the question: what happens when you go past base 10. For example, what about base 11? If you write out the valid range of digits, you'd get '0', '1', ... ,'9', but what comes after '9'? Should you write '10'? That doesn't seem right, because it uses TWO digits. We'd like a way to represent the value 10 with one "symbol".

It's common to use alphabetic characters, where 'A' stands for 10, B for 11, and so forth. Using alphabetic characters only goes so far. You can go up to 'Z' and represent numbers up to base 36.

(In case you're wondering, the base is equivalent to the number of symbols used for a single digit. There are 10 digits from '0' to '9', plus 26 alphabetic characters, so 36 total symbols means you can go up to base 36).

You might wonder what happens if you have go to a higher base. Do you start making up even more symbols?

Here's where we cheat a little. You don't *really* have to
invent even more symbols to represent other digits. What you can do
is to make up a symbol like **v _{i}** where

We still think of this as a 3 digit value. The v's help us determine where the individual digits are.

This is very important! There are some numbers that can't be natively represented on a computer (there are some inefficient ways around this problem, though).

To explore this further, let's
consider an N digit number in base K. How many possible different
N-digit patterns are there? (I occasionally call the numbers,
*patterns*, so don't let that bother you).

The answer requires simple combinatorics. Since each digit
is in base K, there are K choices for the first digit, K choices
for the second digit, and so forth. The answer is to multiply
the choices together to get K multiplied to itself N times,
or simply, K^{N}.

Again, let's consider a simple example. How many 4-digit
base-3 patterns are there? The answer is 3^{4} = 81.
Since these values are contiguous starting at 0, we can represent
numbers from 0 up to 80 in base 3 using exactly 4 base-3 digits.

In elementary school days, you may have been that that digits have places. For example, there's the 1's place, the 10's place, the 100's place and so forth.

Here's an example of "1976" written. The first row
indicates the "place" and the second row are the individual
digits of 1976.

1000's | 100's | 10's | 1's |

1 | 9 | 7 | 6 |

You were taught that you could write these numbers out as:

1976 = (1 * 1000) + (9 * 100) + (7 * 10) + (6 * 1) = 1976In words, you multiplied the digit by its place, and summed the result together. For example, 9 is in the hundred's place, so you multiply 9 by 100.

This elementary school exercise must have seem utterly trivial to you, and perhaps you wondered why you were taught that 1976 happens to equal 1976.

Only this is not nearly as easy as you might think. In elementary school, they may have also taught you Roman numerals. You hardly ever see Roman numerals outside of some copyright years on films (and that's starting to be rare) or the current incarantion of the Super Bowl (which seems to the be last major display of Roman numerals).

Consider a number like DCLXXIX. If memory serves, this Roman numerals for 679 in base 10. Roman numerals have bizarre rules. For example, 7 is written VII. 8 is written VIII. 9 is written IX. When the I comes before the X, it means to subtract 1. Roman numerals have some odd combination of unary values (III meaning 3) and subtraction (such as IX). The rules are more complex than Arabic numerals, the numbers you and I are most familiar with.

Instead of calling it the thousands place, the hundreds places, and so forth, we're going to modify the scheme just a little by using powers of 10.

Thus, we can write:

10^{3} |
10^{2} |
10^{1} |
10^{0} |

1 | 9 | 7 | 6 |

Recall that any positive number raised to the power 0 is 1.

Thus, we can rewrite 1976 as:

1976 = (1 * 10Let's use that notation with the^{3}) + (9 * 10^{2}) + (7 * 10^{1}) + (6 * 10^{0}) = 1976

d_{3} |
d_{2} |
d_{1} |
d_{0} |

10^{3} |
10^{2} |
10^{1} |
10^{0} |

1 | 9 | 7 | 6 |

What do you notice in common between the green rows and the red ones? You'll notice that the subscript of the green rows match the superscript of the red one. For example, d

Earlier on, I said that I'd explain why we number right to left, starting at index 0. This is the reason. The subscripts refer to the power of 10 you multiply the value.

This leads us to the following formula:

The summation formula given above works in other bases, but we
have to modify it somewhat.

Let's try a simple example:

d_{2} |
d_{1} |
d_{0} |

3^{2} |
3^{1} |
3^{0} |

2 | 1 | 2 |

Here, K = 3, so we just use the summation formula:

212If K (the base) is greater than 10, then the problem is a little trickier. You must convert the alphabetic characters to their base 10 values. For example,_{3}= (2 * 3^{2}) + (1 * 3^{1}) + (2 * 3^{0}) = (2 * 9) + (1 * 3) + (2 * 1) = 18 + 3 + 2 = 23_{10}

d_{2} |
d_{1} |
d_{0} |

11^{2} |
11^{1} |
11^{0} |

1 | 1 | A |

We wish to convert

11A_{11}= (1 * 11^{2}) + (1 * 11^{1}) + (A * 11^{0}) = (1 * 121) + (1 * 11) + (10 * 1) = 121 + 11 + 10 = 142_{10}

We only need to extend the summation formula given earlier to handle a finite number of digits left of the radix point and right of the radix point. Assume that we have a N digits left of the radix point and M digits right of the radix point.

The summation formula given in previous sections can be generalized
to:

d_{2} |
d_{1} |
d_{0} |
d_{-1} |
d_{-2} |
d_{-3} |

2^{2} |
2^{1} |
2^{0} |
2^{-1} |
2^{-2} |
2^{-3} |

1 | 0 | 1 | 0 | 1 | 1 |

Using the summation formula, where N=3 and M=3, we get:

101.011Notice that the summation still works. We now add negative subscripts for digits right of the radix point, and just like before, we raise the base to the negative power, based on the subscript._{2}= (1 * 2^{2}) + (0 * 2^{1}) + (A * 2^{0}) + (0 * 2^{-1}) + (1 * 2^{-2}) + (1 * 2^{-3}) = (1 * 4) + (0 * 2) + (1 * 1) + (0 * .5) + (1 * .25) + (1 * .125) = 4 + 0 + 1 + 0 + .25 + .125 = 5.375_{10}

Those are probably the two most pertinent facts presented here.