We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexSuggestions & BugsWebsite,  Documentation,  Book Bugs › shift right documentation wrong
Page Index Toggle Pages: 1
shift right documentation wrong (Read 1629 times)
shift right documentation wrong
Jul 4th, 2009, 12:53am
 
The bitwise right shift function is not documented properly, as
0x80000000 >> 2 returns 0xE0000000 instead of 0x20000000, as it stupidly extends the sign bit.

This will cause lots of problems for people trying to extract bit fields.  

After much searching around I found the correct function for a right shift is actually >>>
Re: shift right documentation wrong
Reply #1 - Jul 4th, 2009, 1:06am
 
It is not stupidly, it is by design (Java uses signed integers) and tradition from C (mm, Microsoft says it is implementation dependent, which is worse!).
Usually, when you do bit field operations, you mask the bit you want (at the end!).
But well, >>> is useful, indeed.
Page Index Toggle Pages: 1