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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:24:33+00:00 2026-06-17T22:24:33+00:00

Possible Duplicate: Why is (-1 >>> 32) = -1? The unsigned right shift operator

  • 0

Possible Duplicate:
Why is (-1 >>> 32) = -1?

The unsigned right shift operator inserts a 0 in the leftmost. So when I do

System.out.println(Integer.toBinaryString(-1>>>30))

output

11

Hence, it is inserting 0 in the left most bit.

System.out.println(Integer.toBinaryString(-1>>>32))

output

11111111111111111111111111111111

Shouldn’t it be 0?

  • 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-17T22:24:34+00:00Added an answer on June 17, 2026 at 10:24 pm

    See http://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.19

    If the promoted type of the left-hand operand is int, only the five lowest-order bits of the right-hand operand are used as the shift distance. It is as if the right-hand operand were subjected to a bitwise logical AND operator & (§15.22.1) with the mask value 0x1f (0b11111). The shift distance actually used is therefore always in the range 0 to 31, inclusive.

    that is -1 >>> 32 is equivalent to -1 >>> 0 and -1 >>> 33 is equivalent to -1 >>> 1
    and, especially confusing, -1 >>> -1 is equivalent to -1 >>> 31

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

Sidebar

Related Questions

Possible Duplicate: Weird behavior of right shift operator Hello Why both numbers from this
Possible Duplicate: C reverse bits in unsigned integer How can I reverse a binary
Possible Duplicate: Print leading zeros with C++ output operator (printf equivalent)? #include <iostream> #include
Possible Duplicate: Unsigned long with negative value Assigning negative numbers to an unsigned int?
Possible Duplicate: What does 'unsigned temp:3' means struct Test { unsigned a : 5;
Possible Duplicate: && operator in Javascript In the sample code of the ExtJS web
Possible Duplicate: Unsigned long with negative value I have written one kernel module which
Possible Duplicate: performance of unsigned vs signed integers I have read somewhere that it's
Possible Duplicate: What does ‘unsigned temp:3’ means I'm learning some kernel code, and came
Possible Duplicate: Why does .Net Framework not use unsigned data types? In The C#

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.