Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Java in General
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
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
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Java in General
Operators
Aruna Balasuriya
Ranch Hand
Posts: 44
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
public class
Test
{
public static void main(
String
[] args) {
System.out.println(-1>>>1);
}
}
result is 2147483647
How ?
Henry Wong
author
Posts: 23951
142
I like...
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
The bit
pattern
for an integer with a value of negative one is ...
1111 1111 1111 1111 1111 1111 1111 1111
When you shift it right by one (using >>>), you get ...
0111 1111 1111 1111 1111 1111 1111 1111
And if you work out the math, converting this binary to decimal,
you should
get the value.
Henry
Books:
Java Threads, 3rd Edition
,
Jini in a Nutshell
, and
Java Gems (contributor)
You had your fun. Now it's time to go to jail. Thanks for your help tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Abstract class
why is the below code not printing 2 i agree its a post increment but its being assigned to x???
A question ...
Why does the below code fail to compile?
regarding class definition
More...