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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:19:34+00:00 2026-06-16T11:19:34+00:00

Example byte b = 127; (initialize be to equal 11111111) Now I only care

  • 0

Example

byte b = 127;

(initialize be to equal 11111111)

Now I only care about bits 1 and 0

how do i bit shift do get 00000011

I think this is called “masking bits” if I’m right?

I tried
b << 5
then
b>> 5
to zero out the other bits but that’s just wrong

My goal

switch ((myByte >> 3) & 3)
{
    case 3:
        resevered = true;
        break;
    case 2:
        open = true;
        break;
    case 1:
        SingleOnly = true;
        break;
    case 0:
        daulMode = true;
        break;
}
  • 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-16T11:19:36+00:00Added an answer on June 16, 2026 at 11:19 am
    b & 0x03
    

    will give you a byte containing the first two bits, with the remaining bits zero-filled.

    This works because 0x03 is 00000011 in binary, and

    11111111
    

    AND

    00000011
    

    zeroes the first six bits, leaving only the remaining two bits.

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

Sidebar

Related Questions

The Java data type byte for example holds data from -128 to 127 in
Consider this contrived, trivial example: var foo = new byte[] {246, 127}; var bar
How to create new type in c#? For example byte has range 0 to
If I have the following example file where each number is represents a byte
How to write byte by byte to socket in PHP? For example how can
I am reading a file byte-by-byte. Say for example i have this byte: 0x41
I am trying an example: String hashAlgorithm =sha-256 ... md=MessageDigest.getInstance(hashAlgorithm); byte[] enteredPasswordDigest = md.digest(policy.getPassword().getBytes());
What could be the regular expression to detect a multi byte string. For example
Here's the problem. I ,for example,have a string 2500.Its converted from byte array into
Example Div: <div class=container> <div class=select1></div> <div class=select2></div> <div class=select3></div> </div> Now I want

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.