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 9004247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:51:38+00:00 2026-06-16T00:51:38+00:00

Because hex is often used to represent things like RGBA color model data, I’m

  • 0

Because hex is often used to represent things like RGBA color model data, I’m trying to find out how to go about taking a large hex string like 0x11AA22BB and split it into separate bytes. (So; 0x11, 0xAA, 0x22, and 0xBB chunks, essentially..). I know that each hex digit can be directly represented by four bits. But breaking up a chain of bits into smaller groups isn’t something that I know how to do, either.

So, I’m sure that there is probably a simple answer to this. I’m sure it probably has something to do with casting it to an array of single bytes, or using bitwise operators or something, but I can’t figure it out. I know that there is also an issue of endianness and how the bytes are organizes (RGBA, ARBG, ABGR, etc.), but right now I’m just looking to understand how to do the splitting so I can get a general understanding of how it works. I’m using C++ but I think that this might not necessarily be specific to that language.

So, to reiterate; How does one take a large hex string like 0x11AA22BB and split it into 0x11, 0xAA, 0x22, 0xBB?

  • 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-16T00:51:39+00:00Added an answer on June 16, 2026 at 12:51 am

    The two ways are mod/div and shift/mask, but both are actually the same way.

    mod/div:

    num = 0x11aa22bb
    while num > 0:
      byte = num % 0x100
      print hex(byte)
      num //= 0x100
    

    shift/mask:

    num = 0x11aa22bb
    while num > 0:
      byte = num & 0xff
      print hex(byte)
      num >>=8
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Because data from file look like this: line 1 is name (first last), next
If we use hex because it's a simplification of binary that makes things easier
I'm taking a hex color value received as a string and converting it to
I need to find the hex characters with the format _x[0-9A-F]{4}_ except when they're
Is it possible to detect binary data in JavaScript? I'd like to be able
I am interfacing with an external device which is sending data in hex format.
I googled about a function how to convert hex to rgb color code <?php
I am trying to represent the maximum 64-bit unsigned value in different bases. For
I've been told this : Computers convert binary data into the hexadecimal (hex) number
Further to this question: Handling and working with binary data HEX with python (and

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.