Java Code Examples for com.google.common.math.LongMath#floorPowerOfTwo()

The following examples show how to use com.google.common.math.LongMath#floorPowerOfTwo() . 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: GuavaLongMathUnitTest.java    From tutorials with MIT License 4 votes vote down vote up
@Test
public void whenFloorPowerOfLong_shouldReturnValue() {
    long result = LongMath.floorPowerOfTwo(30L);
    assertEquals(16L, result);
}
 
Example 2
Source File: MathUtil.java    From vjtools with Apache License 2.0 2 votes vote down vote up
/**
 * 往下找出最接近2的倍数,比如15返回8, 17返回16.
 * 
 * @param value 必须为正数,否则抛出异常.
 */
public static long previousPowerOfTwo(long value) {
	return LongMath.floorPowerOfTwo(value);
}
 
Example 3
Source File: MathUtil.java    From vjtools with Apache License 2.0 2 votes vote down vote up
/**
 * 往下找出最接近2的倍数,比如15返回8, 17返回16.
 * 
 * @param value 必须为正数,否则抛出异常.
 */
public static long previousPowerOfTwo(long value) {
	return LongMath.floorPowerOfTwo(value);
}
 
Example 4
Source File: MathUtil.java    From j360-dubbo-app-all with Apache License 2.0 2 votes vote down vote up
/**
 * 往下找出最接近2的倍数,比如15返回8, 17返回16.
 * 
 * @param value必须为正数,否则抛出异常.
 */
public static long previousPowerOfTwo(long value) {
	return LongMath.floorPowerOfTwo(value);
}