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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:24:15+00:00 2026-05-30T18:24:15+00:00

Currently studying bitwise arithmetic. It’s really easy, because I have some CS background. But

  • 0

Currently studying bitwise arithmetic. It’s really easy, because I have some CS background. But I just don’t understand one moment with this operator.

For example:

variable3 = variableOne & 3;

or

variable3 &= 3;

Actually this doesn’t matter.

I don’t understand how the process of setting the bits to 0 is going on. And how you can process it on the paper?

  • 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-30T18:24:17+00:00Added an answer on May 30, 2026 at 6:24 pm

    Let’s say 5&3, four-bit width:

    0101b = 5dec
    0011b = 3dec
    ------------
    0001b = 1dec
    

    You just & the bits in the same column. And since the & operator only returns 1 when both arguments are 1, the higher bits from 5 not present in 3 are masked out.


    As for your example from the comments:

    $ perl -E 'printf "%b\n", 0x76'
    1110110
    

    And now:

    1110110 = 0x76
    0000011 = 3dec
    -------
    0000010 = 2dec
    

    …and just to validate:

    $ perl -E 'say 0x76&3'
    2
    

    The schema is simple, you just & each column:

    x
    y
    -
    z
    

    Where z is x&y.


    Aha, judging by your comments in the neighbouring answer the problem is elsewhere. Numeric variables do not contain “hexadecimal values” in them. Numeric variables contain a bit pattern representing a number. “A number” is never binary, decimal or hexadecimal. When you say “three”, there’s no number system in play, three is a three no matter what.

    When you say something like var x = 0x76 in the source code, the machine reads the hexadecimal representation of the number, creates a bit pattern representing this number and stores it in the memory corresponding to the variable. And when you then say something like x &= 3, the machine creates a bit pattern representing number three, combines that with the bit pattern stored in the variable and stores the result in the variable.

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

Sidebar

Related Questions

Currently, I don't really have a good method of debugging JavaScript in Internet Explorer and
I'm currently studying indexers chapter, but I'm unable to understand this[int pos] and this[string
I'm currently studying and trying to implement some algorithms. I'm trying to understand Big
I am currently studying for a career in embedded real time engineering. But find
I am currently studying for an exam I'll have on x86 assembly. I didn't
I am currently studying UITabBarController in Apple doc but I haven't clear what is
I'm currently self-studying C for mastering an university project. In that project we have
I am currently studying Fiege-Fiat Shamir and am stuck on quadratic residues. I understand
currently i'm studying MySQL, sorry for my newbie question. Here my question I have
I'm currently studying this tutorial : and I understand completely how to rotate/scale/translate each

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.