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

Method isPowerOfTwo

output/java_guava/1.4.19/LongMath.java:101–103  ·  view source on GitHub ↗

Returns true if x represents a power of two. This differs from Long.bitCount(x) == 1, because Long.bitCount(Long.MIN_VALUE) == 1, but Long#MIN_VALUE is not a power of two.

(long x)

Source from the content-addressed store, hash-verified

99
100
101 public static boolean isPowerOfTwo(long x) {
102 return x > 0 & (x & (x - 1)) == 0;
103 }
104
105 /**
106 * Returns 1 if {@code x < y} as unsigned longs, and 0 otherwise. Assumes that x - y fits into a

Callers 2

isPowerOfTwoMethod · 0.95
log2Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected