Results 1 to 6 of 6

Thread: Base 32 to Base 10 Conversion

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2006
    Posts
    23

    Exclamation Base 32 to Base 10 Conversion

    I've been reading a bit on the net trying to find out how to convert things from base 32 to base 10, but all I find is stuff on hex to dec, bin to dec, and base 16 to base 10. I really really really need help converting from 32 to 10, and I can't find it anywhere. I'm not smart enough to wrap my head around converting them or writing a function on my own that will do it, so if someone can either help me understand it enough so I can write it, or point me in the direction of some already written code, I would be eternally grateful.

    Thanks in advance!

  2. #2
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: Base 32 to Base 10 Conversion

    This may interest you.

  3. #3
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Base 32 to Base 10 Conversion

    Quote Originally Posted by that article
    ' In order to avoid confusion with the numbers 1 and 0, the
    ' letters I and O are skipped. I also seem to recall that the
    ' letter Q and J should be similarly skipped. To do this, you
    ' must change the Select Case statement accordingly.
    according to wikipedia it's 0 & 1 that are skipped

  4. #4
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: Base 32 to Base 10 Conversion

    I think there is some confusion over this conversion system. Read this Article which includes both 0,1 and I,L, and if you compare the table, they are different.

    Right now, dont have enough time to google more on this topic.
    Show Appreciation. Rate Posts.

  5. #5
    Frenzied Member zaza's Avatar
    Join Date
    Apr 2001
    Location
    Borneo Rainforest Habits: Scratching
    Posts
    1,486

    Re: Base 32 to Base 10 Conversion

    To provide a bit of background: the way any such number system is constructed is in units of powers of the base. Think about decimal, numbers under 1000:

    100s | 10s | 1s = 10^2 | 10^1 | 10^0

    Here, the pipe is just used to divide the columns.

    749 is 7 hundreds, 4 tens and 9 ones, or 7(10^2)s, 4(10^1)s and 9(10^0)s

    This extends up as far as you care to count. The maximum value you can have in any one column is 9. This is fairly obvious, because if you make 9 one bigger, you get 10 which is in the next column. Nobody ever says "seven hundred and forty-ten". They say "seven hundred and fifty".


    The same goes for base 32. Your columns will run along the lines of:

    32^2 | 32^1 | 32^0 = 1024 | 32 | 1

    "31" (in decimal), for example, will appear as 31 lots of the 1s column i.e. "0 | 1". "32" (decimal) will appear as "1 | 0", ie one lot of 32 and no lots of 1. 1023 will appear as 0 | 31 | 31, ie (31 lots of 32) + (31 lots of 1) = 992 + 31. 1024 will then be 1 | 0 | 0. And so on.

    You therefore need 32 different symbols for this system, everything from 0 to 31 can appear in a column. Hence the system of using letters as well as numbers.

    Hence any conversion system works in essentially the same way; work from the right character by character and multiply by increasing powers of the base you're using. All you need to do then is decode the symbols you're using.

    If you want to create your own conversion system then you need the following steps:

    Dim "MyNumberString" as a string containing your number.

    1) Determine the base to convert out of.

    2) Set up a loop of i from 1 to Len(MyNumberString)

    3) Get the ith character in MyNumberString from the right

    4) Determine which value between 0 and (base - 1) this character corresponds to

    5) Multiply by the (i-1)th power of (base), because we start at 0

    6) Add all the numbers up.

    and you have a (base) to decimal converter. You can work it just as easily in reverse to convert back, so in theory it wouldn't be too difficult to construct a converter from any base into any other base.


    zaza
    Last edited by zaza; Sep 2nd, 2006 at 10:09 AM.
    I use VB 6, VB.Net 2003 and Office 2010



    Code:
    Excel Graphing | Excel Timer | Excel Tips and Tricks | Add controls in Office | Data tables in Excel | Gaussian random number distribution (VB6/VBA,VB.Net) | Coordinates, Vectors and 3D volumes

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Aug 2006
    Posts
    23

    Re: Base 32 to Base 10 Conversion

    Thanks for the tips. I'm going to give this a shot tonight, I'll let you know how it goes!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width