This is fascinating.

This is fascinating. JS is non-intuitive when doing bitshifts for  large integers unless you understand that the math is all done as signed integers. The solutions (use “>>>” instead of “>>” and wrap all expressions in “( … ) >>> 0”) are robust but ugly.

Originally shared by Jeff Garzik

Yuck.

http://stackoverflow.com/questions/6798111/bitwise-operations-on-32-bit-unsigned-ints