Returns the largest power of two less than or equal to x. This is equivalent to BigInteger.valueOf(2).pow(log2(x, FLOOR)). @throws IllegalArgumentException if x <= 0 @since 20.0
(BigInteger x)
| 69 | */ |
| 70 | |
| 71 | @Beta |
| 72 | public static BigInteger floorPowerOfTwo(BigInteger x) { |
| 73 | return BigInteger.ZERO.setBit(log2(x, RoundingMode.FLOOR)); |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Returns {@code true} if {@code x} represents a power of two. |