@Test public void testPreviousPowerOfTwo() { for(int power = 16; power > 0; power--) { for(int i = (int) Math.pow(2, power) - 1; i >= (int) Math.pow(2, power - 1); i--) { Assert.assertEquals((int) Math.pow(2, power - 1), PowerOfTwo.previousPowerOfTwo(i)); } } Assert.assertEquals(1, PowerOfTwo.previousPowerOfTwo(1)); }
public static int previousPowerOfTwo(int value) { final int power = (int)(Math.log(value) / Math.log(2)); return (int) Math.pow(2, power); }
PowerOfTwo { public static int previousPowerOfTwo(int value) { final int power = (int)(Math.log(value) / Math.log(2)); return (int) Math.pow(2, power); } }
PowerOfTwo { public static int previousPowerOfTwo(int value) { final int power = (int)(Math.log(value) / Math.log(2)); return (int) Math.pow(2, power); }  }
PowerOfTwo { public static int previousPowerOfTwo(int value) { final int power = (int)(Math.log(value) / Math.log(2)); return (int) Math.pow(2, power); }  static int nextPowerOfTwo(int value); static int previousPowerOfTwo(int value); }
PowerOfTwo { public static int previousPowerOfTwo(int value) { final int power = (int)(Math.log(value) / Math.log(2)); return (int) Math.pow(2, power); }  static int nextPowerOfTwo(int value); static int previousPowerOfTwo(int value);  }