Originally posted by Nate Johnson:
What about a left shift? Left shift always pushes a zero on the right end and you lose the high-most bit... so if you left shift enough, you will end up with zero too?
Usually.
This can be a little tricky. When you're performing a shift, if you try to shift (in a single shift) by the size of the variable or more, you'll really end up shifting by your shift distance mod the variable size. For example:
However, if you do the shift in two smaller increments, they'll work as you'd probably expect.
Check on this code for a minute (along with its output) and see if you can follow what's going on. As usual, if you're still confused, just ask.
Corey