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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:25:26+00:00 2026-05-11T17:25:26+00:00

Something any sophomore in CS should be able to answer, but I can’t seem

  • 0

Something any sophomore in CS should be able to answer, but I can’t seem to wrap my head around it…

I have a set of bits, and I need to replace some of the bits with a different set. In a simplified example:

10101010 -original bit set

00001111 -mask showing replacement positions

00001100 -new bit values

10101100 -resulting bit set

Another example:

10101010 -original bit set

00110011 -mask

11111111 -new bit values

10111011 -resulting bit set

It’s trivial to do this by iterating across the bits.

Is it possible to do this using boolean logic (AND, OR, etc.)?

  • 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-11T17:25:26+00:00Added an answer on May 11, 2026 at 5:25 pm
    result = (original & ~mask) | (newbits & mask)
    

    The “& ~mask” part make sure to clear those bits to 0 before the | part.

    The “& mask” part make sure that only proper bits in newbits are used.

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

Sidebar

Related Questions

So this is something that I have not been able to find any documentation
Is there any possibility in the prefix-function of a given pattern to have something
If db_table with set of urls 1,www.something.any/djjjj 2,www.anything.any/nsmms 3,www.google.com etc and i want filter
i have set the timezone to any time zone that the user have for
I just can't seem to be able to run a 301 redirect and rewrite
Does something like this make any sense at all in Java? class A<T extends
Is there any way to do something conditionally in jquery only if IE6 is
Is there any way to implement something similar to Chatroulette without using Flash or
Is there any way to get the caller function with something else than debug_backtrace()?
JSFiddle Is there any way to make something like the X on that link

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.