public void testIsPowerOfTwo() { for (double x : ALL_DOUBLE_CANDIDATES) { boolean expected = x > 0 && !Double.isInfinite(x) && !Double.isNaN(x) && StrictMath.pow(2.0, DoubleMath.log2(x, FLOOR)) == x; assertEquals(expected, DoubleMath.isPowerOfTwo(x)); } }
public void testIsPowerOfTwoYes() { for (int i = -1074; i <= 1023; i++) { assertTrue(DoubleMath.isPowerOfTwo(StrictMath.pow(2.0, i))); } }