converting numbers between number systems

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    converting numbers between number systems

    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)
    Code:
     ∞             ∞
     Σ{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:
    Code:
    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:
    Code:
    a(i) = f(m,n,i,b(j))
    Dormi
  • jkmyoung
    Recognized Expert Top Contributor
    • Mar 2006
    • 2057

    #2
    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.

    Comment

    • Dormilich
      Recognized Expert Expert
      • Aug 2008
      • 8694

      #3
      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)

      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.
      Last edited by Dormilich; Jan 15 '09, 05:25 PM. Reason: some more thoughts on "mod"

      Comment

      • FishVal
        Recognized Expert Specialist
        • Jun 2007
        • 2656

        #4
        Originally posted by Dormilich
        Code:
        a(i) = f(m,n,i,b(j))
        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
        Code:
        a(i) = f(m,n,i,b)

        Comment

        • Dormilich
          Recognized Expert Expert
          • Aug 2008
          • 8694

          #5
          Originally posted by FishVal
          Did you mean
          Code:
          a(i) = f(m,n,i,b)
          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

          Comment

          • jkmyoung
            Recognized Expert Top Contributor
            • Mar 2006
            • 2057

            #6
            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?

            Comment

            • Dormilich
              Recognized Expert Expert
              • Aug 2008
              • 8694

              #7
              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.

              Comment

              Working...