Ok, this has been here for a full day and no one answered. So I'll try my best to answer despite my lack of knowledge in this field. After a lot of googling I found the following:
Are there any libraries that do such a conversion?
I found nothing that allows this type of conversion, the best I found was this: https://codereview.stackexchange.com/questions/78514/all-in-one-number-base-converter
this guy wrote some code to convert between bases, and it seems quite good except it doesn't work for imaginary bases.-keep this thing in mind because you can still use it-.
Is there no way to express all complex numbers (with integer coefficients) in base $2i$ without radix?
No, any complex number with odd imaginary coefficient will require the use of one digit after the point (since the only way to represent 1i
is 10.2
in quarter-imaginary).
Is the euclidean division algorithm the only conversion algorithm?
I'm not sure Euclidean division actually works here, -not in it's simple form-.
However, after some searching I found this question:
https://codegolf.stackexchange.com/questions/69112/output-quater-imaginary-base-numbers-in-binary
This is a code golfing question, you can use the code in the first answer if you don't mind Javascript, and code that no one can understand.
However, the idea behind the code is that you can convert the real part of the complex number, let's call it r
to base -4. And then interlace 0s between them to convert the real part to base 2i
.
1-e.g. 7 in base -4
is 133
, in base 2i
it is 10303
this is
because the powers corresponding to the odd positions in 2i
are the
same powers of -4 i.e. [1,-4,16,-32,.....]
As for the imaginary part, you can divide the imaginary coefficient by 2, and then convert it to -4
base, then you can insert those into the odd position of the base 2i
number to get the imaginary part. The idea is that the odd 2i
powers are [2i,-8i,16i,.....], and dividing those by 2i (dividing the complex coefficient by 2) gets you the base -4
coefficients [1,-4,8,.....]
2-e.g. to convert 7i
to 2i
base, first divide the coefficient by
2, to get 3.5
, which is 130.2
in base -4
, if you just insert
those digits into the odd positions of base 2i
number you get
103000.2
which is 7i
.
finally, you just add the two parts (imaginary and real) to get the complex number as a whole in base 2i
e.g. 7+7i
in base 2i
is equal to: 7
in base 2i
which is 10303
-from 1-e.g. and 7i
in base 2i
which is 103000.2
-from 2-e.g.- the result of which is 113303.2
which is the base 2i
representation of 7+7i
.
Please keep in mind that yesterday was the first time I heard of imaginary base numbers, so I might not be entirely correct.