Thread: Base Conversion - Negative Base

1. Base Conversion - Negative Base

How to convert base-11 (minus 11) to base10 (decimal)?

I am trying to convert a real number present in base minus 11
(base-11) to base10 i.e., decimal. The problem if the number is an
integer then the result is okay but if it has a fractional part then
there is an anomaly in the result. I am showing you my work, it would
be helpful to me to clarify myself.

Test : 1
8163(base10) = 15261(base-11)
15261(base-11) = 8163(base10)
In the above result the both way conversion is all right, I think, if

Test : 2
-135327.5763267536(base10) = 123456.58301111110730617192(base-11)
123456.789A(base-11) = -135327.5763267536(base10)
But this result has the anomaly, I guess the last output i.e.,
123456.789A(base-11) = -135327.5763267536(base10)
is right but another one is wrong.
So how can I convert the fractional part?
Another test :
Test : 3
3.8518518519(base10) = 120.121(base-3)
121.121(base-3) = 3.8518518519(base10)
Here in the first result the integer part (120) is one less than 121.
This outputs are generated by Java programming. As I have no math
written in my copy all are the codes, so I am showing you the output.
I read the article published in Wikipedia on negative base and I
followed the way of the conversion of the integral part, but there is
no information about the fractional part. It will be more helpful to
me if you show me some algorithmic approach if possible along with the
mathematics.
Thank you very much.
I will be waiting for you.

How to convert base-11 (minus 11) to base10 (decimal)?

I am trying to convert a real number present in base minus 11
(base-11) to base10 i.e., decimal. The problem if the number is an
integer then the result is okay but if it has a fractional part then
there is an anomaly in the result. I am showing you my work, it would
be helpful to me to clarify myself.

Test : 1
8163(base10) = 15261(base-11)
15261(base-11) = 8163(base10)
In the above result the both way conversion is all right, I think, if

Test : 2
-135327.5763267536(base10) = 123456.58301111110730617192(base-11)
123456.789A(base-11) = -135327.5763267536(base10)
But this result has the anomaly, I guess the last output i.e.,
123456.789A(base-11) = -135327.5763267536(base10)
is right but another one is wrong.
So how can I convert the fractional part?
Another test :
Test : 3
3.8518518519(base10) = 120.121(base-3)
121.121(base-3) = 3.8518518519(base10)
Here in the first result the integer part (120) is one less than 121.
This outputs are generated by Java programming. As I have no math
written in my copy all are the codes, so I am showing you the output.
I read the article published in Wikipedia on negative base and I
followed the way of the conversion of the integral part, but there is
no information about the fractional part. It will be more helpful to
me if you show me some algorithmic approach if possible along with the
mathematics.
Thank you very much.
I will be waiting for you.
Thanks for the interesting question, I hadn't heard of negative bases before.

I don't have time for a full reply, but you have a bug, in that

121.121 (base-3) = 3.(851) (base10)

but

120.121 (base-3) = 2.(851) (base10)

3. Thank you for giving reply.
Can I ask you one thing? How did you find that bug? Yes you are right.
120.121(base-3) = 2.8518518519(base10)
But what about the reverse procedure?

Can I ask you one thing? How did you find that bug? It will be helpful to me.
I chose those test numbers because the numbers are small enough to be easily typed. I used PARI/GP for the calculation, but any calculator will do. Going from base -3 to base 10 was the easiest direction.

121.121 (base -3) = 1*(-3)^(2) + 2*(-3)^(1) + 1*(-3)^0 + 1*(-3)^(-1) + 2*(-3)^(-2) + 1*(-3)^(-3) (base 10)

120.121 (base -3) = 1*(-3)^(2) + 2*(-3)^(1) + 0*(-3)^0 + 1*(-3)^(-1) + 2*(-3)^(-2) + 1*(-3)^(-3) (base 10)

5. PARI/GP is good language for mathematical calculations. Did you look into this site Negative base? There is an algorithm, a python code given to convert integer decimal number into negative base. And I have already implemented it using JAVA. But the fractional part is giving me the trouble. It will be very helpful to me if you give any information, site link anything. Thank you.

PARI/GP is good language for mathematical calculations. Did you look into this site Negative base? There is an algorithm, a python code given to convert integer decimal number into negative base. And I have already implemented it using JAVA. But the fractional part is giving me the trouble. It will be very helpful to me if you give any information, site link anything. Thank you.
Hey out of curiosity, is this your post?

Java Programming - Base Conversion - Negative Base

I found it while googling.

So, I thought of an indirect way you can convert from decimal with fractional part to negative base. What you can do is express the decimal as p/q where p and q are integers, convert each of them separately into negative base, then divide them using negative base division algorithm. This may not be optimal, but might be easier than figuring out a more "proper" algorithm. (Or it might not be easier, depends on what you have available I suppose.)

So 2.8518518519 would be 28518518519/10000000000, or you could also use 2.(851) = 104/27 if you have the info available. If the denominators are too big, you probably don't want to try this algorithm; a possible way to "fix" it would entail much more work, you could use continued fractions to get best rational approximations for a given denominator upper bound.

I think I'd have to play around with the numbers for quite a while to come up with anything about a better general algorithm for what you're asking.

7. Yea its me. I also post the same question in dream.in.code.
As you said, expressing a fraction in base10 as rational number, then converting the bases of numerator and denominator and then divide them to find corresponding fractional representation in that base. But the problem is that, the division has to be done by the rule of that particular base, not the ordinary decimal division. Isn't it? This is too difficult I think as I am handling too many bases. I need a general rule of division applied to all bases. I am afraid there is no such rule as per my knowledge.
Actually I am designing a calculator, a scientific calculator, I gave its name Super Scientific Calculator. If I could make the Negabase conversion possible, then there will be a choice of conversion between 72 bases (-2 to -36 and 2 to 36). And many more other functions, Complex number, various number theoretic applications etc. I will look forward to hear from you.
Thank you.

Yea its me. I also post the same question in dream.in.code.
As you said, expressing a fraction in base10 as rational number, then converting the bases of numerator and denominator and then divide them to find corresponding fractional representation in that base. But the problem is that, the division has to be done by the rule of that particular base, not the ordinary decimal division. Isn't it? This is too difficult I think as I am handling too many bases. I need a general rule of division applied to all bases. I am afraid there is no such rule as per my knowledge.
Actually I am designing a calculator, a scientific calculator, I gave its name Super Scientific Calculator. If I could make the Negabase conversion possible, then there will be a choice of conversion between 72 bases (-2 to -36 and 2 to 36). And many more other functions, Complex number, various number theoretic applications etc. I will look forward to hear from you.
Thank you.
I usually program in Java, so that's a nice coincidence. I'd like to play around with this, but it will take me some time as I have responsibilities, etc. I also have a few threads on MHF where people are awaiting replies and I've been remiss/busy! So please be patient and hopefully I'll come up with something useful..

converting to a negative ba

Click on a term to search for related topics.