converting numbers between number systems  | Moderator | | Join Date: Aug 2008 Location: Leipzig, Germany
Posts: 3,652
| |
I recently found a problem I haven't seen a good solution yet.
this is just the general conversion from a number between number/notation systems (e.g. decimal, binary, octadecimal notation) - ∞ ∞
-
Σ{a(i)⋅n^i} = Σ{b(j)⋅m^j}
-
–∞ –∞
n, m – base of the number system
a(i) – given coefficients of number in system n
b(j) – unknown coefficients of number in system m
ex: - 10110 (2) = 28 (10)
-
n = 2, a(1) = a(2) = a(4) = 1, a(x) = 0 (x not 1,2 or 4)
-
m = 10, b(0) = 8, b(1) = 2, b(x) = 0 (x not 0 or 1)
the solution I know is an iterative one, but I wonder if there is an analytical solution to this equation at all.
maybe something like:
Dormi
| | Moderator | | Join Date: Mar 2006
Posts: 1,103
| | | re: converting numbers between number systems
Are you trying to find a specific a(i) given variable i, and fixed m, n, and b(j)'s? If so, the solution probably uses specific mod rules, dependent on m and n.
|  | Moderator | | Join Date: Aug 2008 Location: Leipzig, Germany
Posts: 3,652
| | | re: converting numbers between number systems Quote:
Originally Posted by jkmyoung Are you trying to find a specific a(i) given variable i, and fixed m, n, and b(j)'s? no, I want all coefficients a, but I guess the coefficient for a given i (a(i)) depends on i, m, n and all coefficients b. (just feels like that)
(I mixed up a and b in the last code block, but it doesn't matter as long as you imagine b as given, instead of a) Quote:
Originally Posted by jkmyoung If so, the solution probably uses specific mod rules, dependent on m and n. that's what the iteration way uses.
|  | Expert | | Join Date: Jun 2007 Location: Israel
Posts: 2,584
| | | re: converting numbers between number systems Quote:
Originally Posted by Dormilich
Dormi I guess this could not be resolved unless logn(m) is an integer and j*(logn(m)-1)-1 <= i <= j*logn(m)-1.
Did you mean |  | Moderator | | Join Date: Aug 2008 Location: Leipzig, Germany
Posts: 3,652
| | | re: converting numbers between number systems Quote:
Originally Posted by FishVal Did you mean I don't have an idea, what the result function depends on, that's really only a guess.
note: b(j) means "b with index j", but I couldn't make it display this way
| | Moderator | | Join Date: Mar 2006
Posts: 1,103
| | | re: converting numbers between number systems
What is the criteria for solving this? Do you want a faster algorithm? One that takes less space on a computer?
Recursive, eg,
a(i) = f(m,n,i,b a(i-1))
or relate it somehow to another function?
|  | Moderator | | Join Date: Aug 2008 Location: Leipzig, Germany
Posts: 3,652
| | | re: converting numbers between number systems Quote:
Originally Posted by jkmyoung What is the criteria for solving this? not the iterative way (means applying mod n recursively, a.k.a. a(i) = f(m,n,a(i-1)) ), just a solution where each coefficient can be computed separately.
|  | Similar Algorithms / Advanced Math bytes | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,449 network members.
|