@Test public void testSwapBits() { Assert.assertEquals(2, swapBits(2, 1, 1)); Assert.assertEquals(2, swapBits(2, -1, 1)); Assert.assertEquals(2, swapBits(2, 1, 65)); Assert.assertEquals(1, swapBits(2, 0, 1)); Assert.assertEquals(14, swapBits(7, 0, 3)); }
public static long swapBits(final long x, final int i, final int j) { if (j <= i || i < 0 || j > 63) { return x; } final long mask1 = 1L << i; final long mask2 = 1L << j; final long mask = mask1 | mask2; return x ^ mask; }
PracticeQuestionsCh5 { public static long swapBits(final long x, final int i, final int j) { if (j <= i || i < 0 || j > 63) { return x; } final long mask1 = 1L << i; final long mask2 = 1L << j; final long mask = mask1 | mask2; return x ^ mask; } }
PracticeQuestionsCh5 { public static long swapBits(final long x, final int i, final int j) { if (j <= i || i < 0 || j > 63) { return x; } final long mask1 = 1L << i; final long mask2 = 1L << j; final long mask = mask1 | mask2; return x ^ mask; }  }
PracticeQuestionsCh5 { public static long swapBits(final long x, final int i, final int j) { if (j <= i || i < 0 || j > 63) { return x; } final long mask1 = 1L << i; final long mask2 = 1L << j; final long mask = mask1 | mask2; return x ^ mask; }  static long[] computeParities(final long[] input); static long swapBits(final long x, final int i, final int j); static void powerSet(Set<Integer> set); static int stringToInt(String s); static String changeBase(String s, int b1, int b2); }
PracticeQuestionsCh5 { public static long swapBits(final long x, final int i, final int j) { if (j <= i || i < 0 || j > 63) { return x; } final long mask1 = 1L << i; final long mask2 = 1L << j; final long mask = mask1 | mask2; return x ^ mask; }  static long[] computeParities(final long[] input); static long swapBits(final long x, final int i, final int j); static void powerSet(Set<Integer> set); static int stringToInt(String s); static String changeBase(String s, int b1, int b2); static final Logger LOGGER; }