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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:44:08+00:00 2026-06-17T09:44:08+00:00

Can someone please explain the purpose of the bitwise, Binary AND Operator( & )

  • 0

Can someone please explain the purpose of the bitwise, Binary AND Operator( & ) and how to use it? I was looking at different ways of making a isprime function and came across this.

def isprime(n):
    # make sure n is a positive integer
    n = abs(int(n))
    # 0 and 1 are not primes
    if n < 2:
        return False
    # 2 is the only even prime number
    if n == 2: 
        return True    
    # all other even numbers are not primes
    if not n & 1: 
        return False
    # range starts with 3 and only needs to go up the squareroot of n
    # for all odd numbers (counts by 2's)
    for x in range(3, int(n**0.5)+1, 2):
        if n % x == 0:
            return False
    return True

I also looked at Python Bitwise Operators Example but couldn’t grasp it.

  • 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-17T09:44:09+00:00Added an answer on June 17, 2026 at 9:44 am

    One number AND another is the bits of one number masked by the bits of another number. If a number AND 1 is 0 (not n & 1 would be True), that means it’s divisible by two, since all multiples of 2 have a 0 as the rightmost binary digit.

      11 = 00001011 (Not divisible by 2)      28 = 00011100 (Divisible by 2)
    &  1 = 00000001                         &  1 = 00000001
    ---------------                         ---------------
           00000001                                00000000
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone please explain the purpose of double-negating the reverse var in the below
Please someone can explain to me the purpose of the source and dest parameters
Can someone please explain to me, why every time I use the FlowLayout Layout
Can someone please explain this java Regex to me? ^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+(?:[A-Z]{2}|com|org|net|gov|mil|biz|info|mobi|name|in|aero|jobs|museum)$ This regex is used
I'm not quite sure what the purpose of session_names is.. Can someone please explain
Can someone please explain when and why use commit? http://msdn.microsoft.com/en-us/library/ms190295.aspx . 1) Update in
Can someone please explain to me why the equality operator in PowerShell is not
Can someone please explain why ?___SID=U is appearing in some Magento URLs on my
Can someone please explain how Read/Show works.. I cannot find any tutorials on it.
Can someone please explain to me how this responsive approach works? This was done

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.