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

  • Home
  • SEARCH
  • 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 5934939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:11:03+00:00 2026-05-22T15:11:03+00:00

I was wondering what your ideas were in developing an efficient algorithm for doing

  • 0

I was wondering what your ideas were in developing an efficient algorithm for doing if/else switch/cases based on bits. I have 8 bits to play with and I need to divide them into higher order and lower order bits, like so:

0000 1111

Each half contains some information base on which bits are turned on. For example, if the lower half (1111 in this little endian machine) is actually 0010, something happens. Furthermore, if the higher end is 1000, something else happens.

I guess it would be efficient to rightshift the upper half and make AND comparisons (like (x >> 4) & 8) but I’m not sure what’s smart to do for the lower half, as it seems a bit unclever to left shift and compare to some weird number.

Your insights, again, greatly appreciated.

  • 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-22T15:11:04+00:00Added an answer on May 22, 2026 at 3:11 pm

    First of all, the (x >> 4) & 8 in your example isn’t quite right. To compare the higher nibble (the top four bits) to n, you need ((x >> 4) & 15) == n.

    To compare the lower nibble to n, you simply lose the right shift: (x & 15) == n.

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

Sidebar

Related Questions

I am wondering what everyone thinks the best method of handling results from your
thanks in advance for your help. I am wondering if there is a (design)
I was wondering how you guys actually develop large applications when you are your
I was wondering how other developers begin refactoring. What is your first step? How
Wondering if I need to do something in my swf to be able to
Wondering how to open many new windows with Javascript. I have found plenty of
With an application I'm currently developing I've come across the need to serialize some
Wondering if anyone has gotten the infamous database is locked error from Trac and
Wondering if there is any Text to Speech software available as a plug in
Wondering if anybody out there has any success in using the JDEdwards XMLInterop functionality.

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.