This week's book giveaway is in the Kotlin forum.We're giving away four copies of Kotlin for Android App Development and have Peter Sommerhoff on-line!See this thread for details.
Win a copy of Kotlin for Android App Development this week in the Kotlin forum!
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
• Campbell Ritchie
• Liutauras Vilda
• Devaka Cooray
• Jeanne Boyarsky
• Bear Bibeault
Sheriffs:
• Junilu Lacar
• Paul Clapham
• Knute Snortum
Saloon Keepers:
• Ron McLeod
• Tim Moores
• Stephan van Hulst
• salvin francis
• Carey Brown
Bartenders:
• Tim Holloway
• Frits Walraven
• Ganesh Patekar

# why -1>>>32 results in -1

Ranch Hand
Posts: 32
I think this value must be zero.But it outputs -1.

I think >>> operator cannt produce negative numbers.
can any one please explain me how this value is generated.

Rancher
Posts: 42974
76
Section 15.19 of the Java Language Specification 3.0 explains why this is:

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. The shift distance actually used is therefore always in the range 0 to 31, inclusive.

So, no shifting is taking place here. The -1 returned is the original (unshifted) parameter.

Greenhorn
Posts: 27
Is shifting operator is there in java 1.5 exam?

Ranch Hand
Posts: 32
Thanks a lot Ulf Dittmer !!!.

Ulf Dittmer
Rancher
Posts: 42974
76

Is shifting operator is there in java 1.5 exam?

No.

Greenhorn
Posts: 15
2.Any questions on high calculation for bit shifting? Like shifting the bits to x # so that resulting # is big, such questions can consume large amount of time in calculation!!

3.Can SUN have Any questions on AWT, in SCJP1.4?

Greenhorn
Posts: 15
1.Any questions on high calculation for bit shifting? Like shifting the bits to x # so that resulting # is big, such questions can consume large amount of time in calculation!!

2.Can SUN have Any questions on AWT, in SCJP1.4?

Ulf Dittmer
Rancher
Posts: 42974
76
All these questions about what is and isn't in the exam are answered by the exam objectives, which you should study thoroughly before starting to learn.

 All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad: RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database