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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:08:56+00:00 2026-05-23T08:08:56+00:00

Getting my self a bit confused here. I would like to test if a

  • 0

Getting my self a bit confused here.

I would like to test if a set of bits (3 bits) contains a bit in a certain postion.

if (B110 & B010 == B010)

(B110 being the number to check, B010 the bit I want to see if is there)

The above code isn’t giving me the expected out come, both B110 is true and B101 is true. I am pretty sure that I need to use a &(and) to test with the mask B010.

My understanding is that B110 & B010 would be equal to B010 and that B101 & B010 would equal B000. But my if statement is run with both test bits?

I am coding in an Arduino, I’m sure that it’s a simple misunderstanding on my behalf but not sure where.

  • 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-23T08:08:56+00:00Added an answer on May 23, 2026 at 8:08 am

    Try if ((B110 & B010) == B010)

    At the moment it’s running as if (B110 & (B010 == B010)) which will always be true.

    As this table shows, == and != have a higher precedence than &, | etc.

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

Sidebar

Related Questions

Feel like I'm going a bit nutty here. I have a detail view with
I'm getting a bit confused with UIViews recently, I have been using them fine
I'm getting a bit confused how delegation works. I believe the idea is to
Getting this error with jquery & jquery.form. Site has been live for awhile..upgraded to
Self tracking entities. Awesome. Except when you do something like return Db.Users; none of
I've declared a formset like so: class BaseFeatureFormSet(BaseFormSet): def save(self, commit = True): feature
I'm getting a NSObject doesNotRecognizeSelector error when trying to set a property and I'm
Just doing a bit of self teaching on visual basic, I have a list
I'm using this bit of code to capture the iPad screen. I keep getting
I've been playing around with the iOS Facebook SDK and I'm getting a bit

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.