MCPcopy Create free account
hub / github.com/antlr/codebuff / isPowerOfTwo

Method isPowerOfTwo

output/java_guava/1.4.16/BigIntegerMath.java:81–84  ·  view source on GitHub ↗

Returns true if x represents a power of two.

(BigInteger x)

Source from the content-addressed store, hash-verified

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.

Callers 1

log2Method · 0.95

Calls 1

checkNotNullMethod · 0.45

Tested by

no test coverage detected