### Question:
BitReversals { public static int stackOverflowMethod(int x) { x = (x & 0x55555555) << 1 | (x & 0xAAAAAAAA) >>> 1; x = (x & 0x33333333) << 2 | (x & 0xCCCCCCCC) >>> 2; x = (x & 0x0F0F0F0F) << 4 | (x & 0xF0F0F0F0) >>> 4; x = (x & 0x00FF00FF) << 8 | (x & 0xFF00FF00) >>> 8; x = (x & 0x0000FFFF) << 16 | (x & 0xFFFF0000) >>> 16; return x; }  static void main(String[] args); @Benchmark int reverseJdk(); @Benchmark int reverseBasis(); @Benchmark int stackReverse(); @Benchmark int stanfordParallelReverse(); @Benchmark int stanfordSevenOpReverse(); @Benchmark int stanfordMultiplyReverse(); @Benchmark int loopReverse(); static int loopMethod(int v1); static int stanfordSevenOpMethod(int v1); static int stanfordMultiplyMethod(long v1); static int stanfordParallelMethod(int v); static int stackOverflowMethod(int x);  }### Answer:
@Test public void consistency() { for (int i = 0; i < 999999; i++) { int jdkReversed = Integer.reverse(i); int basisReversed = Bytes.reverseBits(i); int stackReversed = stackOverflowMethod(i); boolean consistent = (jdkReversed == basisReversed) && (jdkReversed == stackReversed); if (!consistent) { log.error("not consistent int {} jdk {} basis {} stack {}", i, jdkReversed, basisReversed, stackReversed); throw new RuntimeException("not consistent"); } } }