static int reverseBits(int i, int bits default 32) { int j = 0; repeat bits { j = (j << 1) | (i & 1); i >>>= 1; } ret j; }