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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:54:20+00:00 2026-05-16T22:54:20+00:00

I have an arbitrary 8-bit binary number e.g., 11101101 I have to swap all

  • 0

I have an arbitrary 8-bit binary number e.g., 11101101

I have to swap all the pair of bits like:

Before swapping: 11-10-11-01
After swapping: 11-01-11-10

I was asked this in an interview !

  • 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-16T22:54:21+00:00Added an answer on May 16, 2026 at 10:54 pm

    In pseudo-code:

    x = ((x & 0b10101010) >> 1) | ((x & 0b01010101) << 1)
    

    It works by handling the low bits and high bits of each bit-pair separately and then combining the result:

    • The expression x & 0b10101010 extracts the high bit from each pair, and then >> 1 shifts it to the low bit position.
    • Similarly the expression (x & 0b01010101) << 1 extracts the low bit from each pair and shifts it to the high bit position.
    • The two parts are then combined using bitwise-OR.

    Since not all languages allow you to write binary literals directly, you could write them in for example hexadecimal:

    Binary        Hexadecimal  Decimal 
    0b10101010    0xaa         170
    0b01010101    0x55         85
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an arbitrary number of files that I need to load in an
Here I have an arbitrary IEnumerable<T> . And I'd like to page it using
So I've got some data. There are entities. Entities have an arbitrary number of
I have a class that spawns an arbitrary number of worker object that compute
I have a model that has an arbitrary number of children entities. For simplicity
What I currently have looks a bit like this: if(userLikesBananas) { return from fruit
I have a database that stores an arbitrary number of phone numbers. There are
I have a 128-bit number in hexadecimal stored in a string (from md5, security
Given an arbitrary floating point number, say -0.13 , suppose we have an algorithm
I have an arbitrary XML document provided by a URL. I also have an

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.