Java Code Examples for com.google.common.math.IntMath#isPowerOfTwo()
The following examples show how to use
com.google.common.math.IntMath#isPowerOfTwo() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GuavaMathUnitTest.java From tutorials with MIT License | 5 votes |
@Test public void should_test_if_is_power_of_two() { boolean result1 = IntMath.isPowerOfTwo(8); assertTrue(result1); boolean result2 = IntMath.isPowerOfTwo(9); assertFalse(result2); }
Example 2
Source File: MathUtils.java From fastjgame with Apache License 2.0 | 4 votes |
/** * 判断一个值是否是2的整次幂 */ public static boolean isPowerOfTwo(int value) { return IntMath.isPowerOfTwo(value); }
Example 3
Source File: GuavaIntMathUnitTest.java From tutorials with MIT License | 4 votes |
@Test public void whenIsPowOfInteger_shouldReturnTrueIfPowerOfTwo() { boolean result = IntMath.isPowerOfTwo(16); assertTrue(result); }
Example 4
Source File: GuavaIntMathUnitTest.java From tutorials with MIT License | 4 votes |
@Test public void whenIsPowOfInteger_shouldReturnFalseeIfNotPowerOfTwo() { boolean result = IntMath.isPowerOfTwo(20); assertFalse(result); }
Example 5
Source File: MathUtil.java From vjtools with Apache License 2.0 | 2 votes |
/** * 是否2的倍数 * * @param value 不是正数时总是返回false */ public static boolean isPowerOfTwo(int value) { return IntMath.isPowerOfTwo(value); }
Example 6
Source File: MathUtil.java From vjtools with Apache License 2.0 | 2 votes |
/** * 是否2的倍数 * * @param value 不是正数时总是返回false */ public static boolean isPowerOfTwo(int value) { return IntMath.isPowerOfTwo(value); }
Example 7
Source File: MathUtil.java From j360-dubbo-app-all with Apache License 2.0 | 2 votes |
/** * 是否2的倍数 * * @param value不是正数时总是返回false */ public static boolean isPowerOfTwo(int value) { return IntMath.isPowerOfTwo(value); }