@Test public void testConvertToBase() { Assert.assertNull(changeBase(null, 10, 2)); Assert.assertEquals("", changeBase("", 10, 2)); Assert.assertEquals("1001", changeBase("9", 10, 2)); Assert.assertEquals("1F", changeBase("31", 10, 16)); }
private static StringBuilder convertToBase(int x, int b) { StringBuilder buffer = new StringBuilder(); buffer.insert(0, encode(x % b)); if (x >= b) { buffer.insert(0, convertToBase(x / b, b)); } return buffer; }
PracticeQuestionsCh5 { private static StringBuilder convertToBase(int x, int b) { StringBuilder buffer = new StringBuilder(); buffer.insert(0, encode(x % b)); if (x >= b) { buffer.insert(0, convertToBase(x / b, b)); } return buffer; } }
PracticeQuestionsCh5 { private static StringBuilder convertToBase(int x, int b) { StringBuilder buffer = new StringBuilder(); buffer.insert(0, encode(x % b)); if (x >= b) { buffer.insert(0, convertToBase(x / b, b)); } return buffer; }  }
PracticeQuestionsCh5 { private static StringBuilder convertToBase(int x, int b) { StringBuilder buffer = new StringBuilder(); buffer.insert(0, encode(x % b)); if (x >= b) { buffer.insert(0, convertToBase(x / b, b)); } return buffer; }  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 { private static StringBuilder convertToBase(int x, int b) { StringBuilder buffer = new StringBuilder(); buffer.insert(0, encode(x % b)); if (x >= b) { buffer.insert(0, convertToBase(x / b, b)); } return buffer; }  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; }