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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:05:38+00:00 2026-06-08T19:05:38+00:00

In one byte i set some bits |Video | Audio | speaker | mic

  • 0

In one byte i set some bits
|Video | Audio | speaker | mic | Headphone | Led with bits
|1 | 1 | 1 | 3 | 1 | 1
1 byte for all except for mic which has 3 bytes and thus can have 7 combination leaving
the first combination.

#define Video    0x01
#define Audio    0x02
#define Speaker     0x04
#define MicType1  0x08 
#define MicType2  0x10
#define MicType3  0x20
#define MicType4 (0x08 | 0x10) 
#define MicType5 (0x08 | 0x20)
#define MicType6 (0x10 | 0x20)
#define MicType7 ((0x08 | 0x10) | 0x20)
#define HeadPhone 0x40
#define Led    0x80

Now I set the bits

MySpecs[2] |= (1 << 0);
MySpecs[2] |= (1 << 2);

//set mictype6

MySpecs[2] |= (1 << 4);
MySpecs[2] |= (1 << 5);

when I do read like this

 readCamSpecs()
    {
        if(data[0] &  Video)
            printf("device with Video\n");
        else
            printf("device with no Video\n");
        if(data[0] & Audio) 
            printf("device with Audio\n");
        else
            printf("device with no Audio\n");

        if(data[0] & Mictype7)
            printf("device with Mictype7\n");
        if(data[0] & Mictype6)
            printf("device with Mictype6\n");
    }

The values set with single bits, it can find.
But the values set with multiple bits (e.g, MicType5,6,7) it makes error
and displays whatever is the first in check.
What am I doing wrong?

  • 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-08T19:05:39+00:00Added an answer on June 8, 2026 at 7:05 pm

    Your & check succeeds even when there’s only one bit set, as the result would still be non-zero.

    Try if ( data[0] & Mictype7 == MicType7 ) instead.

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

Sidebar

Related Questions

character set has 1 and 2 byte characters. One byte characters have 0 as
If I would want to operate on pointers which point to one byte should
We've been bashing our heads off of this one all morning. We've got some
Very similar to Changing one byte in a file in C , but in
In .net, does a bool[] use one bit or one byte per array item?
Let a binary string composed of messages separated by one null byte: <message><null><message><null> ...
I have a byte[] member in one of my persistable classes. Normally, I'd just
Google App Engine - When I want to store a byte array as one
Is there any predefined function available to convert a byte into BitArray ? One
one question about PHP Development. I am building up some Form Fields for Calculations.

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.