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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:40:18+00:00 2026-06-17T15:40:18+00:00

Can anyone explain this bitwise operation syntax? #define Bitset(var,bitno) ((var) |=1UL<<(bitno)) I know it

  • 0

Can anyone explain this bitwise operation syntax?

#define Bitset(var,bitno) ((var) |=1UL<<(bitno))

I know it sets the bits of var, but I can’t understand the syntax.

  • 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-17T15:40:19+00:00Added an answer on June 17, 2026 at 3:40 pm

    Let’s break it down, piece by piece:

    1UL is an unsigned long int with a value of 1 represented at the bit level as:

    00000000000000000000000000000001
    

    the << is a “bit shift” operator which will move all the bits in that value above to the left bitno number of times. If it’s 1UL<<5, you’ll end up with:

    00000000000000000000000000100000
    

    Once you have this value, the |= (which is a bitwise OR operation with an assignment) will essentially force the bit of var that’s in line with that 1 to be a 1 and wont touch any other bits because (X | 0 = X)

    Lets say var is 37 and bitno is 7. Then everything at the bit level will look like this:

    00000000000000000000000000100101  // var
    00000000000000000000000010000000  // 1UL<<7
    
    00000000000000000000000010100101  // var | (1UL<<7)
    

    Finally, in case it isn’t clear, the #define marks Bitset as a function-like macro.

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

Sidebar

Related Questions

Can anyone explain this code to me var ParentClass = function(){ } var ChildClass
Can anyone explain this behaviour? var culture = new CultureInfo(da-DK); Thread.CurrentThread.CurrentCulture = culture; daab.StartsWith(da);
Can anyone explain this (code in global scope) var a = a || 4
Can anyone explain this strange behaviour in jQuery? I'm using version 1.5.2. var myxml
Can anyone explain this code to me? Whats the meaning and how to use
Can anyone explain this to me. I'm trying to inject a CSS file onto
Can anyone explain why this code: {% form_theme form _self %} {% block avo_gallery_upload_widget
Can anyone explain why this code with the given routes returns the first route?
Can anyone explain why this query returns an empty result. SELECT * FROM (`bookmarks`)
Can anyone explain me why this throws a findbug warning: if (m != null

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.