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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:56:33+00:00 2026-05-15T21:56:33+00:00

I need to rotate a 64 bit value using 2 32 bit registers. Has

  • 0

I need to rotate a 64 bit value using 2 32 bit registers. Has anyone come across an efficient way of doing this?

  • 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-15T21:56:33+00:00Added an answer on May 15, 2026 at 9:56 pm

    Well, a normal rotate can be implemented like this:

    unsigned int rotate(unsigned int bits, unsigned int n) {
        return bits << n | (bits >> (32 - n));
    }
    

    So, here’s a guess at a 64-bit implementation with 32-bit vars:

    void bit_rotate_left_64(unsigned int hi, unsigned int lo, unsigned int n,
                            unsigned int *out_hi, unsigned int *out_lo) {
        unsigned int hi_shift, hi_rotated;
        unsigned int lo_shift, lo_rotated;
    
        hi_shift = hi << n;
        hi_rotated = hi >> (32 - n);
    
        lo_shift = lo << n;
        lo_rotated = lo >> (32 - n);
    
        *out_hi = hi_shift | lo_rotated;
        *out_lo = lo_shift | hi_rotated;
    }
    

    Basically, I’m just taking the rotated bits from the high word and OR-ing them with the low word, and vice-versa.

    Here’s a quick test:

    int main(int argc, char *argv[]) { 
        /* watch the one move left */
        hi = 0;
        lo = 1;
        for (i = 0; i < 129; i++) {
            bit_rotate_left_64(hi, lo, 1, &hi, &lo);
            printf("Result: %.8x %.8x\n", hi, lo);
        }
    
        /* same as above, but the 0 moves left */
        hi = -1U;
        lo = 0xFFFFFFFF ^ 1;
        for (i = 0; i < 129; i++) {
            bit_rotate_left_64(hi, lo, 1, &hi, &lo);
            printf("Result: %.8x %.8x\n", hi, lo);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to rotate in image multiple times in 90 degrees I am using
I have a directory full of log files that I need to rotate using
I need to rotate objects in a smooth way like Elbert F's freeTransform does.
Has anyone got a bit of code I can use to change the center
I have a one 64-bit integer , which I need to rotate 90 degrees
I started a bit with C # using visual studio 2010 The program has
I need to rotate an image 90 degrees, and I figured using GDI+ would
I need to rotate an image when the user do a two finger twist
I have a point in a rectangle that I need to rotate an arbitrary
I need to write a program that uses matrix multiplication to rotate an image

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.