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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:29:12+00:00 2026-06-15T21:29:12+00:00

-5 / 2 = -2 -5 >> 1 = -3 I learn from my

  • 0
    -5 / 2 = -2

    -5 >> 1 = -3

I learn from my teacher that >>1 divides the number by 2. It works on positive number but it does not work on negative numbers. Can someone explain to me??

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-06-15T21:29:13+00:00Added an answer on June 15, 2026 at 9:29 pm

    As BЈовић & mystical states, using bit shift operators on negative numbers is implementation defined.
    The reason for this is C doesn’t distinguish between logical and arithmetic bit shifting.
    (Arithmetic pads with the most significant bit, logical pads with 0’s)
    for positive numbers this doesn’t matter, for both arithmetic and logical bit shifts would keep the most significant bit as a 0:
    Arithmetic 5>>1
    0000 0000 0000 0101 = 5
    to
    0000 0000 0000 0010 = 2

    Logical 5>>1
    0000 0000 0000 0101 = 5
    to
    0000 0000 0000 0010 = 2

    however with a negative number (2’s comp)
    Arithmetic -5>>1
    1111 1111 1111 1011 = -5
    to
    1111 1111 1111 1101 = -3

    Logical -5>>1
    1111 1111 1111 1011 = -5
    to
    0111 1111 1111 1101 = 32,765

    or at least, this is how i understand it

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

Sidebar

Related Questions

i am looking for repository pattern sample that i can learn from it and
I'm trying to learn C from an unnamed book that contains the following sample
While learning an example from learn-you-a-haskell which right triangle that has integers for all
I want to learn WPF but from all the commentary I've been hearing the
When I was trying to learn from an existing program, I could not understand
I would like to learn from and possibly use the section serializer that Jeff
Apparently my teacher believes that even if we don't have time to learn stuff
Well. Thanks for all your kindly help. I have learn from your that, to
I want to learn APL (more specifically Dyalog APL), but I can't seem to
Some projects that I try and learn from don't have a schema.rb file, why

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.