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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:04:59+00:00 2026-05-15T12:04:59+00:00

I think I might have been asleep in my CS class when they talked

  • 0

I think I might have been asleep in my CS class when they talked about Bit Positions, so I am hoping someone can lend a hand.

I have a unsigned 32-bit integer (Lets use the value: 28)

According to some documentation I am going over, the value of the integer contains flags specifying various things.

Bit positions within the flag are numbered from 1 (low-order) to 32 (high-order).
All undefined flag bits are reserved and must be set to 0.

I have a Table that shows the meanings of the flags, with meaning for the numbers 1-10.

I am hoping that someone can try and explain to me what this all means and how to find the “flag” value(s) from a number like, 28, based off of bit position.

Thanks

  • 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-15T12:05:00+00:00Added an answer on May 15, 2026 at 12:05 pm

    28 converts to 11100 in binary. That means bits 1 and 2 are not set and bits 3, 4 and 5 are set.

    A few points: first, anybody who’s really accustomed to C will usually start the numbering at 0, not 1. Second, you can test of individual flags with the bitwise and operator (&), as in:

    #define flag1 1    //  1 = 00 0001
    #define flag2 2    //  2 = 00 0010
    #define flag3 4    //  4 = 00 0100
    #define flag4 8    //  8 = 00 1000
    #define flag5 16   // 16 = 01 0000
    #define flag6 32   // 32 = 10 0000
    
    if (myvalue & flag1)
        // flag1 was set
    
    if (myvalue & flag4)
        // flag4 was set
    

    and so on. You can also check which bits are set in a loop:

    #include <stdio.h>
    
    int main() { 
        int myvalue = 28;
        int i, iter;
    
        for (i=1, iter=1; i<256; i<<=1, iter++)
            if (myvalue & i)
                printf("Flag: %d set\n", iter);
        return 0;
    }
    

    should print:

    Flag: 3 set
    Flag: 4 set
    Flag: 5 set
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I think it might have been asked before but i was unable to find
I am currently writing a CMS and remember someone (it might have been on
I think I read somewhere recently (might even have been on SO but I
I have an issue that (I think) might have to do with scope, but
I think I might have done something right, headByRating and headByName both refer to
Today I think i might have learned something (not sure), i'm not really a
I am new to Unit Testing and think I might have dug myself into
Merely out of interrest: do you think Java would have been a better language
I have been having issues getting my SQLite Databases to work and I think
I have some PL/SQL code that I think might have a memory leak. Everytime

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.