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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:18:35+00:00 2026-05-31T02:18:35+00:00

First I am not sure what is going on in this bitwise operation. I

  • 0

First I am not sure what is going on in this bitwise operation.
I get code written and supply to other parties as code snippets.

Now if VAR is unsigned 8bit integer (unsigned char) and r is either 0 or 1 or 2 or 4.
Can following be reversed if the value of r is known and resulting value is there.
VAR |= 1 << r; //that is 200 where VAR was 192 and r was 3

For example initial value of VAR is 192 and value of r is 3 *result is 200*.

Now if I have this 200, and I know the value of r that was 3, can I reverse it back to 192 ?

I hope it is most easy one, but I don’t know these bitwise operations, so forgive me.

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-05-31T02:18:36+00:00Added an answer on May 31, 2026 at 2:18 am

    The answer is no. This is because the | (OR) operator is not a one-to-one function.

    In other words, there are multiple values of VAR that can produce the same result.

    For example:

    r = 3;
    var0 = 8;
    var1 = 0;
    
    var0 |= 1 << r;  //  produces 8
    var1 |= 1 << r;  //  produces 8
    

    If you tried to invert it, you wouldn’t be able to tell whether the original value is 0 or 8.

    A similar situation applies to the & AND operator.


    From an information-theory perspective:

    The operators | and & incur a loss of information and do not preserve the entropy of the data.

    On the other hand, operators such as ^ (XOR), +, and - are one-to-one and thus preserve entropy and are invertible.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First of all I'm not sure this is even possible, however I need to
Not sure if you can do this, but I want to select the first
This is a weird problem and I'm not sure what's going on. I installed
This is my first time using git, and I am not sure what is
This seems pretty straight forward but I'm not sure what is going wrong. I'm
Hey guys I'm not sure if I'm going about all this the right way.
I'm not sure how tests first works and I'd like to hear arguments about
First of all, I'm not sure if the title accurately describes what I'm referring
I apologize for making my first question not the hard-hitting code-related question I was
This may be a beginners question but not having much luck getting this going.

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.