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

  • Home
  • SEARCH
  • 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 8347181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:16:57+00:00 2026-06-09T07:16:57+00:00

I have a Hex Array which looks like : 31 31 00 00 00

  • 0

I have a Hex Array which looks like :

31 31 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

When converting this to binary this looks like : 0011000100110001

Each bit is a flag that relates to a number within the array. In this case this binary number would equal 2,3,7,10,11,15.

I’m not sure if there is a name for this notation, but is there any easy method to convert the hex about to get a list of decimal numbers as shown above.

So,

Each 0x31 equates to a byte or 8 bits.

Each 0x31 converts to 00110001.

The way that this binary is then supposed to be interpretted is.

0 1 2 3 4 5 6 7 8 9 10
0 0 1 1 0 0 0 1 ......

Here you can see I get the decimal values 2,3,7 from the 0x31.

Hope this makes sense. Any help would be greatly appreciated.

  • 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-06-09T07:16:58+00:00Added an answer on June 9, 2026 at 7:16 am

    So we have the hex numbers in a space-separated string.

    s = '31 31 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00'
    

    Now we split the string, convert each byte from hex string to int (int('31', 16) == 49), then convert it to binary string (bin(49) == '0b110001'), then take away the '0b' with [2:], add zeroes at the beginning so the sequence exactly 8 long ('110001'.zfill(8) == '00110001'). Then we join all the bit strings together in one string.

    s = ''.join(bin(int(b, 16))[2:].zfill(8) for b in s.split())
    # Now `s` is '0011000100110001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
    
    • An alternative to the above line, that works in Python 2.5:
      trans = {'0':'0000','1':'0001','2':'0010','3':'0011','4':'0100','5':'0101','6':'0110','7':'0111','8':'1000','9':'1001','a':'1010','b':'1011','c':'1100','d':'1101','e':'1110','f':'1111',' ':''}
      s = ''.join(trans[c] for c in s.lower())

    Then we enumerate the bits, so every bit (b) will have a corresponding position (i), just as you described. We use a list comprehension and include only those positions at which the symbol is '1'.

    r = [i for i, b in enumerate(s) if b=='1']
    # Now `r` is [2, 3, 7, 10, 11, 15]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a hex string which looks like: String hexImage =0xFFD8FFE000104A46494600010200006400640000FFEC00114475636B79000100040000003C... Which I need
I have an array of hex codes that translate into assembly instructions and I
I have an array of RGB hex colors. I would like to find a
I have a binary data which I am reading into an array of long
I have a byte array that has hex values and I initially put those
I have a byte array filled with hex numbers and printing it the easy
I have a hex value (0x0020004E0000 ... which is the base address to a
let's say that I have a HEX color #a08040. How can I determine in
I have a string representation of a MD5 hex digest for a file, that
I have some code which takes strings representing hexadecimal numbers - hex colors, actually

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.