Returns true if x represents a power of two.
(BigInteger x)
| 79 | |
| 80 | |
| 81 | public static boolean isPowerOfTwo(BigInteger x) { |
| 82 | checkNotNull(x); |
| 83 | return x.signum() > 0 && x.getLowestSetBit() == x.bitLength() - 1; |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * Returns the base-2 logarithm of {@code x}, rounded according to the specified rounding mode. |