Bit shifting limitations

Henning Thielemann schlepptop at
Mon Jul 14 07:59:40 UTC 2014

Am 13.07.2014 21:49, schrieb Eric Mertens:

> I think defining the behavior of shifts to work modulo the bitSize is no
> better than leaving those ranges undefined. If we were going to define
> what it means to shift outside that range I'd rather it was somehow
> consistent with math multiplying and dividing by powers of two than
> randomly rolling over to a world where shifting a Word32 by 33 somehow
> corresponds to shifting by 1.

What he actually wants, is (x `testBit` mod n 64). I guess "rotate" is 
the better than "shift" here because "rotate" is naturally modular.

More information about the Libraries mailing list