Mark Brossard

Greenhorn
+ Follow
since Aug 24, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Mark Brossard

Thank you Ashish,
I wonder if Marcus Green has been already notified about this?
I'll check the discussion group on his site.
I came across 2 tutorial pages where it says that for a left or right shift (<< and >>) the sign bit will never change.
I tested this with the Bit By Bit applet at http://www.javaranch.com/campfire/StoryBits.jsp
I tried 2 << 30 (integer 2 left shifted by 30 bits) and the result is : -2147483648. (a negative)
Both pages came from the jchq.net site.
From http://www.jchq.net/tutorial/05_01Tut.htm
"The left and right shift operators move the bit pattern to the left or right and leave the sign bit alone."
From http://www.jchq.net/tutorial/BitShift.htm
"Thus a left or right shift (<< and >>) will never cause a number to change its sign. A positive number will always stay positive and a negative number will always stay negative."

Am I missing anything or these two quotes are misleading?
Thanks!