# How does quater-imaginary (and other imaginary/complex bases) work?

So I've been working on a simple base-conversion program, and having given it the ability to convert from decimal to any base $> 1$ or $< 0$, as well as the $p$-adic (bijective, I think?) bases, I decided to tackle imaginary systems.

Unfortunately, I can't seem to understand any of the articles I find about them. The Wikipedia article on quater-imaginary is fairly comprehensible (I feel like I could write an algorithm for converting between decimal and it), but there are a couple of things I don't quite understand (why there are 4 digits, for example).

The article on complex bases is a bit more dense. This is mostly because I know very little of the notation used (and trying to Google it proves difficult, since they tend to be symbols more than words). I think I could extrapolate pure imaginary bases from quater-imaginary (once I've a fuller understanding of it), but I have no idea how to work complex bases at all.

So I guess my question is: Does anyone have any good resources on how complex number systems work? (That is to say, algorithms for converting between decimal and them, why some of the seemingly arbitrary decisions (like the number of digits) were made, et cetera). Not necessarily in simple terms, but at least presented in such a way that I could Google or otherwise find the meaning of any of the things I didn't immediately understand without too much trouble. (I'd rather be spending my time trying to learn about something than trying to search for information about it).

-
You've tried reading Knuth's original article? –  Ｊ. Ｍ. Nov 5 '11 at 1:43
FWIW: conversion to decimal is always an easy task: you can use Horner's algorithm in general, and digit-grouping for bases that are prime powers. –  Ｊ. Ｍ. Nov 5 '11 at 1:45
I've wanted to look into his article, but it doesn't appear to be freely available, and I'd prefer not to have to spend anything if it can be helped. And yeah, decimal->base_n conversions are the things I've been having the most trouble with. –  Jef Nov 5 '11 at 2:07
You might have luck getting a copy at a nearby (university) library. –  Ｊ. Ｍ. Nov 5 '11 at 16:37

Almost four years and no answers? I can't give you a complete answer, but I guess under the theory of better late than never I will try to address as many as your points as I can. Though it's possible that by now you have gotten a better answer through another source.

Does anyone have any good resources on how complex number systems work?

Yeah. Go to Wikipedia and scroll all the way to the bottom, to find the external links. The Gilbert paper looks very good and transparent, and it's available as a PDF. Your local university library might have a copy of Knuth's monumental 3-volume book.

there are a couple of things I don't quite understand (why there are 4 digits, for example).

This is a very interesting question in its own right. I think that first you need to understand "negabases" (numeral systems with a negative number as the base), but before that, I will review some very basic basics of positive integer bases.

You already know, at least on an intuitive level, the basic principle of power series numeral systems with a positive integer as the base. Given a base $b$ and a positive integer $n$ represented by the string of $\mathcal{L}$ digits $\{d_{\mathcal{L} - 1}, d_{\mathcal{L} - 2}, \ldots d_1, d_0 \}$, the string of digits is essentially a shorthand for $$n = \sum_{i = 0}^{\mathcal{L} - 1} d_ib^i$$. Of course this basic principle also works when $b$ is almost anything other than a positive integer greater than 1.

I could be wrong on this next point, but I think that there are only three numbers that are completely unworkable as bases for a power series positional numeral system, namely $-1$, 0 and 1. I think that for a base $b$ to be "workable" for this purpose, the following needs to be true: if $\alpha$ and $\beta$ are distinct integers drawn from $\mathbb{Z}$, then $b^\alpha$ and $b^\beta$ are distinct numbers.

With $b = -1$, $\alpha$ and $\beta$ can be distinct but if they're of the same parity, then $b^\alpha = b^\beta$, and with $b = 1$ they can have different parities. It should be obvious that 0 is completely useless as a base. Other than that, I guess any number whatsoever can work as a base. Of course some bases have more practical value than others. For example, quite a few people think we'd all be better off replacing 10 with 12 as our main number base, but I've never heard anyone say the same for $\sqrt[3]{1729}$.

With complete confidence I can tell you that there are only two digits you must absolutely have in every power series positional numeral system: 0 and 1. You have to have 0 to signify the absence of a specific power of the base. Whether you need any more digits depends on the choice of base. Given an integer $b > 2$, you also need a digit for $b - 1$; in fact you need to be able to represent the integers from 0 to $b - 1$ with a single digit.

It is this need for digits from 2 to $b - 1$ when $b > 2$ that leads to some frustrated expectations when the base is not a positive integer. For example, for $b = 4$, you need digits for 0, 1, 2, 3. You don't need a digit for 4 because that's represented as 10. What digits do you need for "negaquartal," with $b = -4$? Digits for $-1$, $-2$, $-3$? Actually, no (though I suppose that if I really wanted to, I could try to work out a system using such digits; I have not wanted to).

In a philosophical sense, systems with positive bases are incapable of representing negative numbers. Sure, we have the negation operator, but in a sense that is actually a shorthand for "$0 -$." Which is to say that, e.g., $-7$ doesn't represent negative seven, that it actually represents $0 - 7$. It is this perceived shortcoming that negabases address: they can represent negative numbers without the need for a negation operator.

For negaquartal, you need digits for 0, 1, 2, 3. The numbers $-1$, $-2$, $-3$ are not single-digit numbers in this system. But you can't use 10 for 4 because now that means $-4$. So positive 4 is represented as 130, and in general, for $\alpha$ odd, the negaquartal representation of $4^\alpha$ is 13 followed by $\alpha$ 0s; this is tantamount to $4^{\alpha + 1} - 3(4^\alpha)$. The negaquartal representation of $4^\alpha$ with $\alpha$ even is the same as with positive quartal. As for $-3$, that's 11, which means $-4 + 1$.

To represent complex numbers, both positive bases and negative bases have to separate the real part from the imaginary part. That's where complex number bases come in. Quater-imaginary, as you know, has $b = 2i$. As you may have already realied, $2i$ is the principal square root of $-4$. So the way it works out is that to obtain the quater-imaginary representation of a purely real integer, be it negative or positive, you can just take the negaquartal representation and riffle in some zeroes. Thus, $-3$ is 11 in negaquartal and 101 in quater-imaginary. I know I've been longwinded on this one without fully answering your question, but if you've read this far and you understand why quater-imaginary uses 4 digits, I'm happy.

-