I was lying in bed the other night thinking about bases of arithmetic....
You know, it's kinda odd that insomnia due to math isn't that rare, for me.
Anyway, I was thinking about bases of arithmetic, and Hal Clement's throwaway gag in
Still River* about an ancient academic controversy over octal versus duodecimal at the School in his story, and the problem of factoring, and how
weak the theoretic justifications for all those specific bases are.
You may be surprised at this claim. "But octal is clearly the most rational," you might be saying. "Binary is the most fundamental base of arithmetic, and octal is a logical extension of that."
Uh-huh. Logical extension
how, exactly?
If you've got an old 24-bit mainframe?"That just implies hexadecimal is even better."
Yeah, okay, but that's still just
one advantage – convenient relation to binary. Besides, larger bases get more and more inconvenient as you have to memorize more and more figures and (more importantly) bigger and bigger multiplication tables. So hex is great for computer scientists, and octal used to be great for computer scientists, but that doesn't translate to their being the best
day-to-day radices. They've got one advantage – one huge advantage – but it's only a
useful advantage in a few contexts.
And when we turn to duodecimal, base 12 (and its cousin, sexagesimal, base 60), we find a similar sole advantage: the base has many factors. Yeah, that's great if you're writing fractions – 1/3 becomes 0.4
duodecimal, 4/15 becomes [00].[16]
sexagesimal (each bracket is a decimal representation of one figure), etc. – but how often do you need to?
Actually, that gets to the key point: what do you need to do regularly with a number system? Really, it comes down to:
- Write.
- Add.
- Subtract.
- Multiply.
- Divide.
...pretty much in that order. I mention "write" because while
messing with the basic principle of positional notation may be fun, standard positional notation is a pretty solid, intuitive way to write down how many books you have on the second shelf of your bookcase.** And while binary may be logically the simplest radix, 10101 takes up a lot more space than 21†. (Oh, and just
coming up with symbols for a sexagesimal system is horrid, forgetting all its other disadvantages.)
So, what about these others? Well, we're only looking at standard positional systems, so whatever advantages
balanced ternary systems have, we're ignoring them. Anyway, in standard positional systems, 'add' and 'subtract' pretty much make only one contribution to complexity: how many digits are in your basic addition tables. And since we humans have shown that we can handle base 10 pretty well, anything up to around that size is probably fine. Multiplication is almost the same, but there's an advantage for highly composite (and not-quite-highly composite) radices – all the rows with divisors of the base are simpler. (I guess that means duodecimal isn't quite as pointless as I thought.) Division – well, you're doing long division, so have to come up with a compromise between having fewer digits (higher radix) and fewer multiples of the denominator (lower radix). Oh, and having lots of divisors means fewer recurring 'decimals'.
This sounds like it's building up to sell duodecimal after all. No, it isn't.
I'm saying we should use senary. Base six.
The actual inspiration for this came that night, when I was comparing duodecimal and octal to decimal. Duodecimal, I had decided, had the advantage of many factors. Octal, of being a power of 2. But what about decimal?
Well, as it happens, I had already realized that decimal was unusually good at testing divisibility. As it happens, there are two types of numbers that are very easy to check divisibility of in a given base: factors of the base, and adjacent natural numbers to the base. In decimal, the first group consists of 2, 5, and 10. The latter group consists of 9 and 11. Divisibility by the first set can be checked through examining the final digit – an even digit means multiple of 2, 5 or 0 mean multiple of 5, 0 means multiple of 10. This is really easy – in big O notation, it's O(1), meaning it takes a constant length of time for any number. As for 9 and 11, it's easy to prove from modulo arithmetic that you need merely add all the digits (for 9 – 'casting out nines', basically) or alternately add and subtract (for 11) to check divisibility. These are both O(log n) – the time they take is proportional to the length of the number, written out.‡
Now, all bases get the benefits of these two effects. But because 9 is a power of 3, in base 10 this means that testing divisibility by 2, 3, 5, and 11 is easy. Four of the first five prime factors, accounting for 75.76% of all numbers. That's pretty good – only missing the seven. Duodecimal only gets 2 and 3 from its factors, and 11 and 13 from the casting-out methods, so it misses five
and seven. Octal would get seven, of course (one less than the base), but it only has two as a prime factor and nine = three squared as one over the base, so it misses five.
But six doesn't. It misses eleven, but with seven it gets 77.14%, better than base 10, which beat bases 8 and 12. It's smaller than 10, which means only six symbols and 21 unique entries each on the addition and multiplication tables. (It would be 36, but since 2+3 = 3+2 and 2*3 = 3*2, a large fraction drop out.) Being smaller also makes long division easier – you need only write 5 multiples of the divisor, instead of 9. Against that, you've got longer numbers, but even when you get pretty large (e.g. the age of the universe, 13.7 billion years), it's not a big difference (13 senary figures as opposed to 11 decimal figures). Being divisible by 2 and 3 means 1/2, 1/3, and 1/4 are all easy (1/4 = 0.13
senary), and adds extra simplicity to two rows of the multiplication table (which has only six to start with, including the ones row).
Add these factors together, and I think that makes 6 the perfect base.
§But hey, who cares what I think!
[
Poll #924107]
* Which is actually a pretty lame book, on rereading, but I still like it.
** Not that bijective numerations are that hard to count in – I just didn't want every link to be to Wikipedia.
† I'm not counting the Adobe Photoshop manual in this count.
‡ Which, you must note, is often much less than the number itself.
§ Yes, I did in fact spent seven hours writing a long, technical discussion of the relative merits of five different systems of positional notation, combined with an a priori enumeration of the most important principles of a number system, just so I could conclude with that sentence. I regret nothing!