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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:23:31+00:00 2026-06-15T04:23:31+00:00

Possible Duplicate: convert big endian to little endian in C [without using provided func]

  • 0

Possible Duplicate:
convert big endian to little endian in C [without using provided func]

I’m having trouble with this one part: If I wanted to take a 32 bit number, and I want to shift its bytes (1 byte = 8 bits) from big endian to little endian form. For example:

Lets say I have the number 1.

In 32 bits this is what it would look like:

1st byte 2nd byte 3rd byte 4th byte
00000000 00000000 00000000 00000001

I want it so that it looks like this:

4th byte 3rd byte 2nd byte 1st byte 
00000001 00000000 00000000 00000000 

so that the byte with the least significant value appears first. I was thinking you can use a for loop, but I’m not exactly sure on how to shift bits/bytes in C++. For example if a user entered in 1 and I had to shift it’s bits like the above example, I’m not sure how I would convert 1 into bits, then shift. Could anyone point me in the right direction? Thanks!

  • 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-15T04:23:32+00:00Added an answer on June 15, 2026 at 4:23 am

    << and >> is the bitwise shift operators in C and most other C style languages.

    One way to do what you want is:

    int value = 1;
    uint x = (uint)value;
    int valueShifted = 
        ( x << 24) |                // Move 4th byte to 1st
        ((x << 8) & 0x00ff0000) |  // Move 2nd byte to 3rd
        ((x >> 8) & 0x0000ff00) |  // Move 3rd byte to 2nd
        ( x >> 24);                 // Move 4th byte to 1st
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How to convert a factor to an integer\numeric without a loss of
Possible Duplicate: How to convert yyyy-MM-dd HH:mm:ss to “15th Apr 2010” using PHP I
Possible Duplicate: Convert multidimensional array into single array I have this array: Array (
Possible Duplicate: convert string to 2D array using php I have the string like
Possible Duplicate: Convert HTML to PDF in .NET I am using VSTS 2008 +
Possible Duplicate: convert xml to jsonx using xslt Can anyone help me out in
Possible Duplicate: Convert one date format into another in PHP Convert date format yyyy-mm-dd
Possible Duplicate: Convert one date format into another in PHP I know there are
Possible Duplicate: Convert ipad application to iphone. Universal app I created one application which
Possible Duplicate: Convert one date format into another in PHP Starting from: $date =

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.