MCPcopy Create free account
hub / github.com/VCVRack/Rack / isPow2

Function isPow2

include/math.hpp:87–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

85/** Returns whether `n` is a power of 2. */
86template <typename T>
87bool isPow2(T n) {
88 return n > 0 && (n & (n - 1)) == 0;
89}
90
91/** Returns 1 for positive numbers, -1 for negative numbers, and 0 for zero.
92See https://en.wikipedia.org/wiki/Sign_function.

Callers 2

ispow2Function · 0.85
ispow2iFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected