On Thu, 2015-09-03 at 13:58 -0700, Roland McGrath wrote: > What about: > w >>= n % 32; > w >>= (n - (n % 32)) % 32; > ?
I don't think that works. For the interesting case n == 32, you won't shift at all. Because both expressions (32 % 32) and ((32 - 0) % 32) evaluate to zero. I prefer the simpler: if (n < sizeof (w) * 8) w >>= n; else w = 0; Which simply states what value we expect for w. Cheers, Mark
