Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6143503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:31:56+00:00 2026-05-23T18:31:56+00:00

Ok so going from Base 32 hex (aka. Triacontakaidecimal) to integer is pretty easy

  • 0

Ok so going from Base 32 hex (aka. Triacontakaidecimal) to integer is pretty easy for example:

>>>int("v", 32)
31

How do you do it the other way around however? I was thinking of setting up a dictionary if a method doesn’t exist to do so.

EDIT:

I actually got this working with the dictionary, the idea of my this method was to take a base 32 hex character and increment it if the LSB wasn’t set to 1

>>> def incHex(hexChar):
...     intRep = int(hexChar, 32)
...     binRep = bin(intRep)
...     if(binRep[-1:]!='1'):
...         intRep += 1
...     convDict = {0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,10:'A',11:'B',12:'C',
...                 13:'D',14:'E',15:'F',16:'G',17:'H',18:'I',19:'J',20:'K',21:'L',
...                 22:'M',23:'N',24:'O',25:'P',26:'Q',27:'R',28:'S',29:'T',30:'U',
...                 31:'V'}
...     return convDict[intRep]
...
>>> incHex('l')
'L'
>>> incHex('m')
'N'
>>>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T18:31:56+00:00Added an answer on May 23, 2026 at 6:31 pm

    A dictionary is probably a little bit of overkill for what you want to do. Why not just use a tuple:

    convTable = ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V')
    

    That will make lookups faster while saving you memory as well.

    If you are just looking up integers in the range 0-31 then you can just do:

    getHex32Rep(val):
        return convTable[val]
    

    Also, you probably want to do:

    if(binRep[-1]!='1'):
    

    instead of

    if(binRep[-1:]!='1'):
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Going from the example given here... http://ericswann.org/blog/archive/2009/04/06/linq-to-sql-datacontext-provider-revisited.aspx I'm trying to use the datacontext between
I'm using the facedetect example and going from there. Right now it only detects
I have a line (actually a cube) going from (x1,y1,z1) to (x2,y2,z2). I would
I'm trying to display edges going from right to left (i.e. backwards) using dot:
I'm trying to replace a div with created elements, going from: <div id='links'></div> to
Given the extremely high requirements for unpredictability to prevent casinos from going bankrupt, what
We would like to force encryption of the data going to and from our
While going through university and from following the development of SO, I've heard a
I am going to start a C# project from scratch that will consist of
Leading on from my previous questions I am going to try and clarify one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.